Code First migrations and dotConnect for Oracle

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
cbruen1
Posts: 9
Joined: Wed 23 Nov 2011 20:18

Code First migrations and dotConnect for Oracle

Post by cbruen1 » Tue 05 Mar 2013 12:21

Hi - I'm attempting to upgrade my project to use Code First Migrations. Currently I have a VS 2012 MVC4 project using Entity Framework Code First 4.2 and DevArt dotConnect for Oracle version 6.8. I upgraded dotConnect to version 7 and EF to version 5 and had various issues for which I made the changes below:

I've added this code to my Configuration class constructor:

Code: Select all

SetSqlGenerator(OracleConnectionInfo.InvariantName, new OracleEntityMigrationSqlGenerator());
and this to my DbContext class:

Code: Select all

var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance; 
  config.Workarounds.IgnoreSchemaName = true;
  config.Workarounds.ColumnTypeCasingConventionCompatibility = true;
and this to the app.config section of my DB project:

Code: Select all

    <dependentAssembly>
      <assemblyIdentity name="EntityFramework"
publicKeyToken="b77a5c561934e089" />
      <bindingRedirect oldVersion="4.4.0.0" newVersion="5.0.0.0" />
    </dependentAssembly>
After doing all the above I deleted the Migrations folder in VS and ran Enable-Migrations again. This produced the Configuration class as well as a {Timestamp}_InitialCreate.cs so it seemed to be ok. I then ran 'Add-Migration TestMig2' without making any changes and I now get the error below:

Code: Select all

PM> Add-Migration TestMig2
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at MyAppDatabase.Migrations.Configuration..ctor()
Some questions:

- What version of Entity Framework and dotConnect should I be using?
- Do the config changes detailed above still apply?
- I'm seeing these changes scattered across various posts here and on Stackoverflow. Are all these changes detailed somewhere, or is there a blog post about using Code First migrations with dotConnect for Oracle and all the changes required?

If anyone has any tips or can point out something I might be doing wrong then I'd be grateful..thanks in advance.

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

Re: Code First migrations and dotConnect for Oracle

Post by Shalex » Wed 06 Mar 2013 14:28

cbruen1 wrote:and this to the app.config section of my DB project:

Code: Select all

    <dependentAssembly>
      <assemblyIdentity name="EntityFramework"
publicKeyToken="b77a5c561934e089" />
      <bindingRedirect oldVersion="4.4.0.0" newVersion="5.0.0.0" />
    </dependentAssembly>
There is no need in bindingRedirect in the current implementation of dotConnect for Oracle. Just add the references to the correct versions of the assemblies (depending on the value of Target Framework in your project).
cbruen1 wrote:I upgraded dotConnect to version 7 and EF to version 5
1. If Target Framework in your project is .NET 4.5, add references to:
a) EntityFramework.dll v 5.0.0.0
b) \Program Files\Devart\dotConnect\Oracle\Entity\EF5\Devart.Data.Oracle.Entity.dll
с) \Program Files\Devart\dotConnect\Oracle\Entity\EF5\Devart.Data.Oracle.Entity.Migrations.dll
2. If Target Framework in your project is .NET 4.0, add references to:
a) EntityFramework.dll v 4.4.0.0
b) \Program Files\Devart\dotConnect\Oracle\Entity\EF4\Devart.Data.Oracle.Entity.dll
с) \Program Files\Devart\dotConnect\Oracle\Entity\EF4\Devart.Data.Oracle.Entity.Migrations.dll
cbruen1 wrote:

Code: Select all

System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.3.1.0
It seems like Devart.Data.Oracle.Entity.dll from the old version of dotConnect for Oracle is loaded in the process of your application. To check this, run your application in the debug mode and navigate to VS > Debug > Windows > Modules.

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

Re: Code First migrations and dotConnect for Oracle

Post by cbruen1 » Sun 10 Mar 2013 15:24

Thanks a lot think I'm finally getting my head around it :)

Post Reply