-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
How to make a database able to use migrations, in code, after it was created using EnsureCreate #26870
Comments
@dgxhubbard This is essentially the same as having an existing database that you then want to start using migrations with. We are tracking #2167 to make this better, and also dotnet/EntityFramework.Docs#91 to document it. The general approach for this is to create an initial migration, and then to edit that migration and remove all the code from the public partial class StartingPoint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
} When this migration is applied, it won't change the database (since the database is already in the correct state anyway) but it will create the |
@ajcvickers this helped me. thanks for this tip One quick question. Should we remove the content of the |
@santosh-jallapuram Not sure; @bricelam? |
@ajcvickers |
@ajcvickers |
That code will only be used if you try to |
We are using EF Core 5.
We have a databases for a product that were created using EnsureCreated. We have added migrations to the
product. We need to migrate in code, so we use the Migrate, which is great. I did the migrate and nothing happened. Come to find our databases created using EnsureCreated cannot be migrated. How can we update databases in the field, in code, so that we can call Migrate?
The text was updated successfully, but these errors were encountered: