I have a Asp.Net core 2.0 project, with Entity framework Core 2.0Version. I have an existing database. Now enter packagemanager console window: Add-Migration then Name:InitialMigration after Migration folder added in my project. Then I Type Update-Database comment in package manager console window. 'Table already exists' error message display. Because already that table have in my db.
My requirement is when add or remove property in my existing model that property automatically update in my existing database. how can i do it?
You must remove database and update database after re-create migration. But if you want update in your database tables, you can create another migration and update database without remove existing "InitialMigration".
After adding property in your Entity create new migration and output will be like below;
And you can update database with update with Update-Database command or;
You should see added new column with null values to all rows in database.
Or, you can add custom attribute on your property like below;
And override OnModelCreating method in your DbContext and use this extension below;
This attribute and extension method in my library. I couldn't add documentation because I didn't have time, but there is documentation within the code and sample app exists in github project.
I hope I could help.