Issue with database-first to code-first transition.
Steps to reproduce
- Install-Package Microsoft.EntityFrameworkCore.Tools -Pre
- Install-Package Microsoft.EntityFrameworkCore.SqlServer -Pre
- Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design -Pre
- cd src
- cd MyProject
- dotnet ef dbcontext scaffold -c ApplicationDbContext -o Models "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer --force
- dotnet ef migrations add "Initial"
- dotnet ef database update
The issue
At this point (step 8), it would seem to me that since there were no changes to the model since the scaffold, there would be no updates. Dotnet-ef-database-update attempts to recreate the entire database schema. I think there used to be an -IgnoreChanges switch on add-migrations to help with this issue.
The goal
I want to start database first and have dotnet-ef-dbcontext-scaffold perform the heavy lifting of creating a ton of classes and setup the object relations based on the database schema. Then I want to switch to code-first; add Identity Framework to the project; and use dotnet-ef-migrations-add to add the identity tables using a migration then continue in a code-first fashion from then on. Perhaps my approach is wrong?
Further technical details
EF Core version:
"Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
Operating system: Windows 10 Enterprise Visual Studio version: VS 2015 Enterprise
Possibly a dupe of the scenario described in #2167
Proposal #1 from #2167 "...add a way to point our reverse engineering engine to the existing database to obtain a model snapshot (and possibly an accompanying initial migration)." would seem to address the issue.
Closing as dupe