There is an application using EntityFramework as ORM. It is necessary to fasten the database migration to this application. EF Code First Migrations are currently under review.

For data structure migration, the DbMigration class provides special methods ( AddTable , AddColumn , etc.). To migrate the data itself, according to the information from here :

But there are some arbitrary commands that can be run.

It is proposed to execute SQL scripts by calling the Sql , SqlFile and SqlResource .

It is assumed that the application can support work with different DBMS (SqlServer, Oracle, Postgre). Since Sql-scripts of migrations can (and most likely will) differ from each other for different DBMS, the question arises how to choose the right script depending on the DBMS?

I assume that you need to write a code like:

 if (IsSqlServer) { SqlFile("Script1_SqlServer.sql"); } else if (IsOracle) { SqlFile("Script1_Oracle.sql"); } 

If I am right, then how is it more appropriate to organize a DBMS check (get IsSqlServer, IsOracle values)? If not, what should be done to migrate data?

  • On the idea of stackoverflow.com/q/31344303/5752652 at the time of migration, you do not know what connection string is used, so it will not be easy to get to this data. - AK
  • @AK, Database is an instance context property. Is it assumed that I need to create a context as part of the migration? - Vlad
  • Here's more on your topic thought. Yes, it would be simpler at runtime ... - AK
  • @AK, well, I had thoughts about picking in connection lines. But it seems to me some kind of crutches. It is assumed that ORM is enough to change the provider to make it work for another DBMS. It is extremely unclear why the same is not assumed for migration. - Vlad

0