I am running an application that uses custom migrations (the auto generated ones don't fit my requirements). I am trying to understand how to control in which order the Entity Framework will run those migrations. I read on some places that using timestamp on the file names will do it, but that does not work. (it runs 20190131153312_bla before 20190131153208_bla2, for example)
No matter where I look I can't seem to find information on this subject... can anyone help?
Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.
By default, the migrations assembly is the assembly containing the DbContext. Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project."
One way to create multiple migration sets is to use one DbContext type per provider. Specify the context type when adding new migrations. You don't need to specify the output directory for subsequent migrations since they are created as siblings to the last one.
Migration file and class names doesn't matter.
The order of migrations is determined by the migration identifier (string), which is provided by the Id property of the MigrationAttribute associated with the Migration derived classes.
EF Core tools prepend timestamp to the user supplied migration names in order to ensure proper string ordering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With