C
C#•13h ago
Chaba

Migration Error

Hello, I created migration by this code ( dotnet ef migrations add firstmigration ) and I had to delete it for some reasons I just deleted Migrations folder from Visual Studio and when I am trying to recreate migration from cmd with same code ( dotnet ef migrations add firstmigration ) it shows this error ( shown in image ) and what could be wrong? Thank you.
No description
No description
8 Replies
Anchy
Anchy•12h ago
did you clear your migrations in your database I don't work a lot with EF Core but I believe there is a table to track migrations in your DB
Chaba
ChabaOP•12h ago
With dotnet ef migrations remove?
Anchy
Anchy•12h ago
that is how you should remove a migration instead of deleting it yourself from disk, and I think that handles removing the migration from the database as well
Chaba
ChabaOP•12h ago
I deleted whole database also 😬 I deleted it from the disk instead of cmd and I think that’s problem and now I am struggling with clearing this migration
Anchy
Anchy•12h ago
make sure you save your files as well based on the error it looks like you are trying to register the DbContext itself multiple times if you don't think you are doing that then you could try clean the solution: Build -> Clean
Chaba
ChabaOP•12h ago
I double checked it and I have used DbContext only once and I also tried dotnet clean
Anchy
Anchy•12h ago
I see your are using a db context factory, where is this being used?
Unknown User
Unknown User•6h ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?