问题
I have never experienced this before. SSMS is displaying data tables incorrectly. SSMS seems to be locked into some previous query result and I don't see how to clear it.
I have an application (MVC) that interfaces to an SQL server. When I run the application's database data delete function, the application shows the table to be empty. But SSMS still shows data in the table.
If I then run the application's database seed function, the application shows the table to be re-loaded and I can tell that the data tables are changed because the key index values have incremented. But, SSMS is still stuck on the older data set.
The only conclusion I can derive is that the SSMS query seems to be stuck. What causes this, and how can I get past it?
What I've tried:
First, I ran the SSMS install program and performed a repair, but that didn't solve the problem. I also uninstalled and re-installed SSMS and that didn't remove the problem.
Second, I totally deleted one of the databases from within SSMS, manually. Then from within Visual Studio's Package Manager Console I ran an Update-Database command to quickly recreate the database with its various tables. After that, SSMS began showing the proper data again.
Third, I've also noticed if I manually delete all records in a table from within SSMS, that seems to also clear the problem. I say 'seems to also clear', because when I did this operation on a local SQL server, the problem cleared immediately, but on a remote SQL server, the problem didn't clear immediately; but later that problem seems cleared. The delayed clear of the problem wasn't directly related to the time delay of working a SQL server remotely.
I can do the 2nd and 3rd ideas right now in development; but once in production, that's not a solution. Plus, it doesn't seem to hold. So, I'd like to find out how to 'reset' the SSMS queries.
Added after original post: In reviewing what is different in the project and what changed recently, this may be connected to Visual Studio migrations, but I don't know how. In another SO post I asked about simplifying my database design to simplify my code. The result is that I used Visual Studio migrations to create different databases with a common design. I performed the following EF Migration commands against a single database context:
A single: Enable-Migrations
A single: Add-Migration
Multiple: Update-Database (one for each database)
It now seems that maybe something in this process could be confusing SSMS along the lines of @Larnu's comment below, but it's beyond me to understand.
来源:https://stackoverflow.com/questions/61463638/what-might-cause-ssms-queries-to-reflect-incorrect-data-and-how-can-we-clear-the