Reputation: 962
In ef 7, i created an initial migration using command 'dnx ef migrations add Initial'. When i run the application database was created for me, all good.
Then i updated my entity objects (CSharp files). Now how can i do:
I am getting error: An object already exists in database.
Also, any resources where i can find good practical examples for entity framework code first, as i am struggling to get to speed.
Thanks, Javed
Upvotes: 3
Views: 6101
Reputation: 229
Here's an in depth guide to using EF7 Migrations tools from Julie Lerman, a Microsoft MVP.
https://msdn.microsoft.com/en-us/magazine/mt614250.aspx
Upvotes: 1
Reputation: 962
Looks like i figure it out:
Add initial migration (our your first one). Command 'dnx ef migrations add Initial'
Run the application which will create the database for you.
Add a new migration again. DO NOT DELETE existing migration. Command: 'dnx ef migrations add Migration2'
Update your database. Command 'dnx ef database update Migration2 -v'
Hope it helps anyone.
Upvotes: 8