Database Migrations Problem

Database Migrations Problem

Postby pwarren » Mon 10 Mar 2014 09:30

I am using PostgreSQL with MVC4/EF4 and attempting to set up automatic migrations. Here are the steps I have taken:

* Run the Postgres CRMDemo succesfully
* Run my model and the database is created (I have to create the database manually first, but that's ok)
* Run the Enable-Migrations –EnableAutomaticMigrations command in Package Manager Console
* Configure postgres in my configuration.cs file:

Code: Select all
public Configuration()
            AutomaticMigrationsEnabled = true;
            SetSqlGenerator(PgSqlConnectionInfo.InvariantName, new PgSqlEntityMigrationSqlGenerator());

After that my project will not build:

Code: Select all
Error   1   Assembly 'Devart.Data.PostgreSql.Entity, Version=, Culture=neutral, PublicKeyToken=09af7300eec23701' uses 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' which has a higher version than referenced assembly 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'   ...\bin\Devart.Data.PostgreSql.Entity.dll   Roam
and 2 other PgSqlConnectionInfo conflicts.

* I tried the suggested redirect but to no avail:

Code: Select all
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
            <bindingRedirect oldVersion="" newVersion="" />

I cannot use EntityFramework 6 as I am limited to MVC4 in VS2010.

Anybody have automatic migrations working ?

Paul W
Posts: 4
Joined: Mon 10 Mar 2014 09:02

Re: Database Migrations Problem

Postby Shalex » Thu 13 Mar 2014 18:23

Please make sure that:
1) you have downloaded CrmDemo.EFCodeFirst sample from
2) the project includes references to both
\Program Files\Devart\dotConnect\PostgreSQL\Entity\EF4\Devart.Data.PostgreSql.Entity.dll
\Program Files\Devart\dotConnect\PostgreSQL\Entity\EF4\Devart.Data.PostgreSql.Entity.Migrations.dll
also check via Debug > Windows > Modules that they are loaded in the process of application when debugging

If this doesn't help, send us a small test project for reproducing.
Devart Team
Posts: 7659
Joined: Thu 14 Aug 2008 12:44

Re: Database Migrations Problem

Postby pwarren » Fri 14 Mar 2014 14:15

I have managed to get this working now. Thanks for your pointers. The problem was that as I was publishing my project to a test server, I had added the Devart.Data.PostgreSql.Entity.dll to the bin folder. Following an abortive episode with EF5, I had to backtrack to EF4, and even though I was adding a new reference to the Devart EF4 dll, Visual Studio was picking up the one in my bin folder. I cleared out the bin folder and all the references, added them back and everything now works a treat.
Posts: 4
Joined: Mon 10 Mar 2014 09:02

Return to dotConnect for PostgreSQL