In entity framework core I have created an initial migration using following command
dotnet ef migrations add InitialCreate dotnet ef database update
With this command the database created with the some intial tables from C# entity classes.
Then I am trying to add new C# entity classes (or in future update my entity classes ).
I need to update the database with the newer changes. How I can do it?
When trying to apply same command again
dotnet ef migrations add NameOfNewScript dotnet ef database update
With first command the changes getting reflected in code and new migration file also created in migration folder. But with the second command I am getting error:
An object already exists in database. (for which already created first time)
But it works when drop the database manually and then apply the command.
So how we can manage this without droping the database and apply only post changes?
dotnet ef database update NameOfNewScript -v
Try this. Hope this works for you.