Update model from database: Visual Studio uses the wrong database - visual-studio

I have a project with multiple EF databases; each EF model is in its own project, referenced from the other parts of the database.
Occasionally when I use the Update Model from Database... feature (right-clicking the graphical .EDMX view), Visual Studio gets into a state where it tries to update the .EDMX file for model A from the database associated with model B. For example, it shows "new tables" in the DB that it wants to import (which are actually in the other DB). Even exiting/restarting Visual Studio doesn't resolve the problem.
This question seemed to express the problem I'm seeing, but the accepted answer doesn't address my issue.
What is Visual Studio using to configure how it connects to the DB to find updates? Things I have checked:
My app.config connectionString in the DB project points to the right place. This is the file I would expect it to use.
I have tried setting the "Current Startup Project" to a an application that doesn't reference the "incorrect" DB project, thinking perhaps other projects' app/web.config connectionStrings might interfere; no visible effect.
Server Explorer shows a data connection to the "correct" DB, but not the "incorrect" one. This is probably a red herring; it showed as disconnected until I clicked on it, so I doubt it was being used anyway.
There is no string matching the name of the "incorrect" project/DB in the .csproj file. The .sln file contains only the expected project references. There is no .csproj.user file.
Any ideas? Is this a Visual Studio bug?
UPDATE: Other things tried:
Deleting the .suo file doesn't affect the problem.
I found some unexpected .datasource files that Visual Studio added under Properties at some point; moving these elsewhere hasn't had an effect, and Visual Studio hasn't attempted to recreate them. I looked inside, there's nothing referencing the other DB/project, just a GenericObjectDataSource element with items referencing the "correct" project. The presence of this file makes me suspicious but I'm currently stumped for how to probe further. I don't see equivalent files in any of the other projects in the solution.

/facepalm
Disregard. There were lingering tables in the "correct" database left over from the team's refactor of those tables out into the other database. The phantom tables were actually there in the DB.

Related

Schema Comparison causes Visual Studio 2010 to crash

When I click on Write Updates and then I confirm, VS stops working. What could be the issue here?
I'm trying to update the database project schema directly from the source database using a schema comparison, as it seems it is the absolute best way to sync those, but I seem unable to execute it on the target project. I haven't tried targeting a database.
http://i.stack.imgur.com/lSUpQ.png

Reload database objects in a VS database project?

if I create a SQL Server 2008 Database Project in Visual Studio 2010, then I am able to right click the project and select Import Database Objects and Settings.... I can do that exactly one time (even if I get an error while importing). If I did it one time, the option is grayed-out.
But after I have imported my objects, I couldn't find a way to reload or refresh the objects. A good example would be, that I have a database project of a whole database and someone adds something to the database directly. Now I want to have new table (function, procedure, etc.) in my project, too.
There has to be a better way than copy&paste to add new existing database objects to my database project?
I found this question:
Script all SQL database objects into VS Database project
But I neither have a Schema Compare option, nor can I drag&drop files from the server explorer.
In Visual Studio you should see a menu choice that says Data. If you click on that, you should be able to run a Schema Compare. If you're not seeing that, then there's something wrong with your VS install or the project or maybe both.

Visual Studio 2010 - Database Projects (where are the project template for just script files?)

VS.NET 2010 removed the database project template that could be used for just script files
(that you right click on and execute on desired database).
I want to add a database project similar to the ones in VS.NET 2008? Can i do this?
I tried to use one of the new vs.net 2010 database projects however, in our environment we have multiple applications within the same database. We also have a lot of legacy stuff. In addition we have a lot of queries that cross databases (i.e. in the case of accessing data wharehouse tables). It sure seems that this scenario is hard to use with the new database projects. It seems this adds a lot of complexity to using the new db projects.
What sort of database project is best to be used for this scenario??

Recover a Visual Studio project that was never saved

I started a new project this morning and, after putting ~3 hours of work into it, I tried to open a file from another project to get some code from it. I got a warning about discarding an unsaved object. After telling it to go ahead, I realized that it was referring to the project I had just been working on and not another file that I had just opened.
Even though I never saved the project, the various files containing my code and dataset had to exist on the hard-drive. Are they still there, perhaps in a temp folder? I'm developing on a box running Server 2008 R2 (don't ask, not my decision :) ).
This may help:
http://blogs.msdn.com/b/saraford/archive/2008/02/14/did-you-know-where-visual-studio-saves-auto-recovered-files-in-the-case-of-an-unexpected-shutdown-151.aspx
Also check C:\Users{Username}\AppData\Local\Temporary Projects
You could try one of those undelete programs and see if it finds anything.
Tools > Options > Projects and Solutions
and check the item
Save new projects when created
Save frequently. :)
Need to give one related input. Who the hell had the idea to implement this feature???
I used Visual Studio until 2003, then came back again to 2010 now.
After 2 days work, saving all the time, as I used to (Ctrl + S), I close the project and decide not to save the solution itself.
Done. All lost. Nothing can be recovered from anywhere in the computer.
How can a developer implement a dumb idea such as dropping all work in an "in memory" project.
You either know about it already or you will get screwed; like thousands found on Google during my desperate search.
Did Microsoft VS team look at it at least?
So frustrating...
It might be worth checking out the folder where AutoRecover files are saved.
You can find the default file location in Visual Studio on the Tools - Options menu. Look in the Projects and Solutions section - expand that and look in General to find the default file locations.
My files were under C:\My Documents\Visual Studio 2008\Backup Files.
I had this happen to me this morning. I worked on a new project yesterday and windows ran an update last night. Despite having debugged my program - the project had not saved - for some reason it didn't occur to me that the project might not be saved. I left the program running on my computer when I went to bed. This morning when I work up, I saw that windows had run an update. A few hours later, I saw that my computer had no trace of my program. I realize this is an old post, but I thought I would shed some light on what I did, since i was able to recover my files.
First I went here: http://windows.microsoft.com/en-us/windows7/recover-lost-or-deleted-files
In Visual Basic 2010 Express, a backup folder is created with your project name. Sure enough, my project backckup folder was there: Documents\Visual Studio 2010\Backup Files\MyProject. But, the folder was empty. I "restored this folder to a previous version" using the steps listed in the link above. After doing that, the folder was still empty, BUT, the temporary folder "C:\Users{Username}\AppData\Local\Temporary Projects" now contained my project's folder and files. Prior to running the "restore to previous version", the temporary projects folder was also empty.
So, I was able to copy the folder out of the Temporary Projects folder and I am as happy as one can be - or close to it.
Hope that helps someone out.
A note to the answers above, I had a mini jumpscare when i could not find my project anywhere, not in the recent projects nor in the visual studio projects folder.
I eventually found the project in the visual studio projects folder of the admin user;
I was looking at:
C:\Users\LocalUser\Documents\Visual Studio 2015\Projects
Whilst the project was saved under:
C:\Users\LocalAdmin\Documents\Visual Studio 2015\Projects
Bottom line is; also check the \documents of the admin user. This likely happend because i was testing an admin only application and visual studio was running with the admin's user profile loaded.

Source control binding status is invalid: Visual Studio 2005 and VSS

I had my VB.NET project and associated solution (developed in Visual Studio 2005) in Visual Source Safe.
Recently started working with another developer and needed to clean up.
Somewhere along the way I broke a binding. I went into
File -> Source Control -> Change Source Control
and tried to bind things correctly.
I unbound the project that was incorrectly bound, and tried to rebind it. I have two projects in the solution. This is what I get:
Solution/Project Server Name Server Binding Connected Status
Solution: MySoln.sln X:\TheSource $/Tools/MySoln checked Valid
Project1 X:\TheSource $/Tools/MySoln checked Valid
Project2 X:\TheSource $/Tools/MySoln (C:\) checked Invalid
Where else would I look to try to get the bindings correct?
I may not have given enough information, but this is all I know to give.
Thanks as always!
The little question mark button is occasionally helpful.
Needed to check in that project to source control, and the binding became valid.
which version of VSS are you using?
In older versions of Visual SourceSafe (before 6.0c), after adding a solution of Visual Studio to its source control, the binding information was stored directly in the .sln and .proj files.
Since VSS 6.0c, all binding information is kept locally in files named MSSCCPRJ.SCC on the developer's machine.
My guess, the server path for project2 is incorrect. Double check the .prj file is under $/Tools/MySoln.

Resources