JetBrains / rider-efcore

Entity Framework Core UI plugin for JetBrains Rider
https://plugins.jetbrains.com/plugin/18147-entity-framework-core-ui
MIT License
176 stars 15 forks source link

Update database - does not recognize previous migrations and target migrations is set to "0" #212

Closed Spiros94 closed 7 months ago

Spiros94 commented 7 months ago

Describe the bug

I have a solution of multiple projects inside. Using right click in my project "Entity Framework Core" -> "Update Database.." a new popup window opens. The target migration is set to "0" and there are no other options even thought I have a migrations folder full of migrations! Also this was used to work some weeks ago.

My appsettings.Development.json has multiple commented "sqlServer" connection string and one uncommented. (i don't know if this plays a role here). Except the actual project code, I have changed nothing in project or my sql server. I don't know where to even start checking what it's not sees my Migrations folder (as it was working a few weeks ago)

Environment (please complete the following information):

Thank you in advance

seclerp commented 7 months ago

Hi @Spiros94, thanks for the issue. Please check that you selected the correct Migrations project, Startup project, and DbContext in the dialog's UI, their default order may been changed

Spiros94 commented 7 months ago

Hello @seclerp, thank you for your guidance. I checked everything (tried to change various dropdowns trying to force the dialog to re-check) but with no positive results at all.

Interesting facts after some testing: 1) My Windows 10 did some updates - I restarted the computer and the thing worked. I tried to break it again (and I succeeded :-) ) by switching the view in the left explorer tab to file system - assemblies. 2) When first loaded (after the update restart) the dialog before opening seemed load things. After the breakage, the dialog seems to not load anything - something like a cache is in place, or maybe it does this very fast(?) 3) I tried disabling - re-enabling the plugin with no effect. 4) I tried (with the plugin enabled) to restart my computer with no effect. 5) Changing "Migrations project" in the dialog window, does not seem to affect anything - does not seem to search in folder (I don't know if it is doing this in the background). 6) AppDbContext is in another project (in the same solution) - don't know if it matters.

I cleared my caches (Window's disk cleanup) - restarted multiple times, by I persist that is something cached in my project rather than the computer it self. I cannot explain yet how it worked after restart/update, maybe it's a coincidence.

I am pointing it out again that it was working not problem a few weeks ago.

Spiros94 commented 7 months ago

Tryied out everything and I found this in the Rider enviroment:

Menu in the top left (three lines) -> Invalidate Caches -> I checked all tickboxes -> Invalidated and Restart and now it works!

seclerp commented 7 months ago

Great news! Has this problem disappeared completely?

Spiros94 commented 7 months ago

Great news! Has this problem disappeared completely?

I cannot reproduce the problem using any combination I was using before. I cannot really understand the why and how this problem came up.

seclerp commented 7 months ago

Well, this is also a new type of issue report for me - but from the symptoms and resolution you posted, I may suppose that for some reason PSI caches due to some Rider update or maybe an unhappy crash got corrupted. That's why invalidation helped. Anyway, thanks for the case!