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.


49 Replies
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
With dotnet ef migrations remove?
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
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
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
I double checked it and I have used DbContext only once and I also tried dotnet clean
I see your are using a db context factory, where is this being used?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
It’s in BookStoreDbContext if you’re talking about that
Wdym? Can’t understand sorry
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
For context, this thread seems to be a continuation of this one: https://discord.com/channels/143867839282020352/1409556507229421671
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Oh alright mate, thanks
I am gonna check it
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
This migration things is confusing thing
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
As error says problem is in BookStoreDbContext and it should be about IDesignTimeContextFactory
But i could not find any
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
No
I will upload it later if u need to
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Okay sure
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Gonna upload it at evening not at home atm
Okay
Will let u know when I will upload
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
That’s the point. There was migrations folder ( that I deleted ), I also deleted whole DB before I knew I had to do it from cmd with code. but now, as I get this migration is saved somewhere else which still exists and that’s reason I can’t create new
I will check this docs
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
No
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Lemme show u
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
MsSql
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
dbo ig
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View

@TeBeCo
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
I haven't even connected it to SSMS if u're talking about that

Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Is it normal just to change this code to other version? Or do i need to update something else
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
got it
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Alright im gonna try it
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
That’s what I thought about targetframework versions but there was some more errors when I was trying to install some entity frameworks
That’s why i kept older version
And I am gonna change it now
I am gonna fix it anyways i got it already
You just changed versions and appsettings.json and this started working?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Alright
Thanks mate
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View