What are the challenges you face when working across database platforms? Take the survey
Options

Does SCA support EF Core Code-First Migrations?

We are investigating using SCA to help with migrations in our EF Core 2.1 code-first project. The issue leading us to look at SCA is when deploying migrations to the target database using the CLI the dotnet tool needs access to the source code. E.g. 
dotnet ef database update --project .\Core.DataModel\Core.DataModel.csproj --startup-project Core\Core.csproj
All the examples seem to be for EF6 and if I go through the code-first tutorial at https://documentation.red-gate.com/sca3/tutorials/worked-examples/work-with-entity-framework-codefirst-migrations I get errors when issuing the command below saying the command is unrecognised
Update-Database -Script -Source $InitialDatabase
Any help or advice here would be appreciated.
Tagged:

Answers

  • Options
    Our integration with Entity Framework only works with 6.x and earlier; we rely on the Automatic Migrations feature to generate T-SQL migrations, which was not ported across to EF Core. This means that a database-first approach is now required when working with EF Core, rather than using EF's model of the database to generate migrations.

    The basic steps for a db-first workflow are:

    1.      Modify the database with the desired changes
    2.      Use the SCA tool-window to import the changes into the project. This generates a script based on the model that SCA maintains.
    3.      Modify the model classes in EF Core to reflect the changes
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
Sign In or Register to comment.