How to update new migrations changes?

c# entity-framework-core

Question

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?

1
1
8/8/2017 4:59:22 AM

Popular Answer

dotnet ef database update NameOfNewScript -v

Try this. Hope this works for you.

0
8/7/2017 5:53:02 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow