Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with database-first to code-first transition. #5770

Closed
WillBaldwin opened this issue Jun 14, 2016 · 3 comments
Closed

Issue with database-first to code-first transition. #5770

WillBaldwin opened this issue Jun 14, 2016 · 3 comments

Comments

@WillBaldwin
Copy link

Steps to reproduce

  1. Install-Package Microsoft.EntityFrameworkCore.Tools -Pre
  2. Install-Package Microsoft.EntityFrameworkCore.SqlServer -Pre
  3. Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design -Pre
  4. cd src
  5. cd MyProject
  6. dotnet ef dbcontext scaffold -c ApplicationDbContext -o Models "Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer --force
  7. dotnet ef migrations add "Initial"
  8. 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

@bricelam
Copy link
Contributor

Possibly a dupe of the scenario described in #2167

@WillBaldwin
Copy link
Author

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.

@rowanmiller
Copy link
Contributor

Closing as dupe

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants