C
C#•2mo 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
49 Replies
Anchy
Anchy•2mo 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•2mo ago
With dotnet ef migrations remove?
Anchy
Anchy•2mo 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•2mo 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•2mo 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•2mo ago
I double checked it and I have used DbContext only once and I also tried dotnet clean
Anchy
Anchy•2mo ago
I see your are using a db context factory, where is this being used?
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
It’s in BookStoreDbContext if you’re talking about that Wdym? Can’t understand sorry
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius•2mo ago
For context, this thread seems to be a continuation of this one: https://discord.com/channels/143867839282020352/1409556507229421671
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Oh alright mate, thanks I am gonna check it
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
This migration things is confusing thing
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
As error says problem is in BookStoreDbContext and it should be about IDesignTimeContextFactory But i could not find any
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
No I will upload it later if u need to
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Okay sure
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Gonna upload it at evening not at home atm Okay Will let u know when I will upload
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
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
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
No
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Lemme show u
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
MsSql
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
dbo ig
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
No description
Chaba
ChabaOP•2mo ago
@TeBeCo
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
I haven't even connected it to SSMS if u're talking about that
No description
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Is it normal just to change this code to other version? Or do i need to update something else
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
got it
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Alright im gonna try it
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
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
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Chaba
ChabaOP•2mo ago
Alright Thanks mate
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?