Code First Migrations - Empty migration classes

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
moxitose
Posts: 2
Joined: Wed 01 Feb 2012 17:27

Code First Migrations - Empty migration classes

Post by moxitose » Wed 01 Feb 2012 17:35

Why aren't my migrations being scaffolded like the are for SQL server? I mean, there are no best guesses as to what has changed... I just get a basic skelleton with the Up() and Down() methods

Am I missing something or is this not (yet) supported? Thanks!

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 07 Feb 2012 16:12

Our products support EF Code-First Migrations.
You can follow, for an example, this tutorial for the generation of migrations:
http://blogs.msdn.com/b/adonet/archive/ ... rough.aspx

Be aware that some additional settings should be implemented:

1. Add references to the Devart.Data.Oracle.Entity.dll and Devart.Data.Oracle.Entity.Migrations.dll assemblies to your project (these assemblies' names are for dotConnect for Oracle; other dotConnect providers include corresponding Devart.Data.Xxx.Entity.dll and Devart.Data.Xxx.Entity.Migrations.dll).

2. At first it is necessary to register SQL Generator in the constructor of the Configuration class which is a descendant of DbMigrationsConfiguration (it can be added to the user's project using the Enable-Migrations command in Package Manager Console):

Code: Select all

  SetSqlGenerator(OracleConnectionInfo.InvariantName, new OracleEntityMigrationSqlGenerator());
The same for other dotConnect providers:

Code: Select all

  SetSqlGenerator(MySqlConnectionInfo.InvariantName, new MySqlEntityMigrationSqlGenerator());
  SetSqlGenerator(PgSqlConnectionInfo.InvariantName, new PgSqlEntityMigrationSqlGenerator());
  SetSqlGenerator(SQLiteConnectionInfo.InvariantName, new SQLiteEntityMigrationSqlGenerator());
If you are working with dotConnect for Oracle, you should configure EF-provider for EF Code-First Migrations additionally (for example, it can be done in the constructor of your class-descendant of DbContext):

Code: Select all

  var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;  
  config.Workarounds.IgnoreSchemaName = true;
  config.Workarounds.ColumnTypeCasingConventionCompatibility = true;
If you are working with dotConnect for MySQL (or PostgreSQL or SQLite), it is enough to turn on only IgnoreSchemaName:

Code: Select all

  var config = Devart.Data.MySql.Entity.Configuration.MySqlEntityProviderConfig.Instance;  
  config.Workarounds.IgnoreSchemaName = true;

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 07 Feb 2012 16:16

We are planning to publish a detailed article concerning this topic in our blog in the nearest feature.

cbruen1
Posts: 9
Joined: Wed 23 Nov 2011 20:18

Re: Code First Migrations - Empty migration classes

Post by cbruen1 » Wed 06 Mar 2013 09:41

Did you publish an article regarding this topic? If so maybe you could link to it..

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Code First Migrations - Empty migration classes

Post by Shalex » Wed 06 Mar 2013 13:18

Here is a link to the corresponding article: http://blogs.devart.com/dotconnect/enti ... qlite.html.

The EF6-specific notes: http://blogs.devart.com/dotconnect/enti ... force.html.

StefanAim
Posts: 9
Joined: Mon 02 Sep 2013 14:01

Re: Code First Migrations - Empty migration classes

Post by StefanAim » Mon 25 Nov 2013 14:08

Shalex,

I implemented the sample from msdn for EF 4.3 and EF 5.0.
It works. But when I follow your steps I get many errors.
E.g. "Unable to find the requested .Net Framework Data Provider"

Do you have a full sample?

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Code First Migrations - Empty migration classes

Post by Shalex » Thu 28 Nov 2013 09:16

StefanAim wrote:"Unable to find the requested .Net Framework Data Provider"
This error should gone after registration of "Devart.Data.Oracle" in the DbProviderFactories section like you did in this post: http://forums.devart.com/viewtopic.php? ... 384#p96658.
StefanAim wrote:Do you have a full sample?
We are working on the EF6-specific sample.
At the moment the following articles are available:

Post Reply