I'm using EF6.0 and implementing my db with SQLServerDatabaseProject. I want to use the EF Migration tools for Database migration. but since I have my database on DbProject I want all my migration files to be SQLFiles (not c#) So I would like to know if EF supports this feature and if not, is it possible to write a new Migration class which keeps the EF features but works this way?
Please also consider that I don't want EF to generate my migrations but I would like to be able to use other migration commands such as update-database and ...
==MORE DETAILS ABOUT THE QUESTION==
I don't want to have c# classes load my sql files. The sql files must be saved for up and down migrations directly and be treated exactly as if they are the DbMigration classes. A simple example of Migrations dir would be something like this:
Migrations
-> up
-> 201510060807125_alter-course-change-family.sql
-> 201510060813136_alter-course-add-mark-column.sql
-> down
-> 201510060807125_alter-course-change-family.sql
-> 201510060813136_alter-course-add-mark-column.sql
Database Migration Scripts Are Tool-Dependent This time, the file is in XML format. In actual fact, Liquibase can produce migration changes (or changesets, as they like to call them) in multiple formats such as XML and JSON.
A SQL migration script is similar to a SQL build script, except that it changes a database from one version to another, rather than builds it from scratch. Although they're simple in essence, it is worth knowing how to use them effectively for stress-free database updates and deployments.
Code First Migrations will run the migration pipeline but instead of actually applying the changes it will write them out to a . sql file for you. Once the script is generated, it is opened for you in Visual Studio, ready for you to view or save.
Simply in the migration class use SqlFile
extension method:
public partial class MyFancyMigration : DbMigration
{
public override void Up()
{
SqlFile("myUpSQLFile.sql");
}
public override void Down()
{
SqlFile("myDownSQLFile.sql");
}
}
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