Page 1 of 1

Should there be an EF5 folder / dll

Posted: Fri 05 Apr 2013 15:58
by ACassells
I am trying to migrate an existing SQL Server based app targetting .Net 4.5, using EF5 to a PostGres backend using dotConnect. I have downloaded the trial version and when I try and run a migration I get the error.
[Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
With all the various version numbering confusion of EF and .Net I think that the DevArt .dll that needs this was compiled under .Net 4.0 which will give the 5.0 EF dll the 4.4.0.0 version. If this is the case, to use EF5 there will need to be an dotConnect EF dll, is this true or am I missing something.

Re: Should there be an EF5 folder / dll

Posted: Mon 08 Apr 2013 10:46
by ACassells
To follow up on this, I have created 2 identical projects in VS2012. One of them targeting .Net 4.0 the other targeting .Net 4.5.

The 4.0 project, when you install Entity Framework adds a reference to a EF .dll 4.4.0.0
The 4.5 project, when you install Entity Framework adds a reference to a EF .dll 5.0.0.0

I have created a simple entity and context, enabled and added a migration, and set the SqlGenerator to be PgSqlEntityMigrationSqlGenerator on both projects.

When I create the db in postgres and run Update-Database on 4.0 I get the desired tables created.

When I create the db in postgres and run Update-Database on 4.5 I get

Code: Select all

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.4.0.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 Ef_Postgres_4_5_Test.Migrations.Configuration..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.CreateConfiguration(Type configurationType)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
Exception has been thrown by the target of an invocation.
I think there is an obvious issue with EF5 migrations on .Net 4.5 . I am more than happy to share these 2 test projects. Is this a known issue or is there any work around?

Re: Should there be an EF5 folder / dll

Posted: Mon 08 Apr 2013 13:23
by Shalex
Please add the reference to Entity/EF4/Devart.Data.PostgreSql.Entity.dll in your .NET 4.5 (EF5) project which uses dotConnect for PostgreSQL.
ACassells wrote:When I create the db in postgres and run Update-Database on 4.5 I get

Code: Select all

Could not load file or assembly 'EntityFramework, Version=4.4.0.0, ...
Add the following XML in the *.config file of your application to solve the problem:

Code: Select all

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
      <bindingRedirect oldVersion="4.4.0.0" newVersion="5.0.0.0" />
    </dependentAssembly>
    </assemblyBinding>
  </runtime>

Re: Should there be an EF5 folder / dll

Posted: Mon 08 Apr 2013 15:00
by ACassells
Brilliant, thank you for that.

Re: Should there be an EF5 folder / dll

Posted: Thu 27 Oct 2016 21:33
by jazz albert
I messed up with aforementioned script and unable to get it out?
infantigoPiercingHealth

Re: Should there be an EF5 folder / dll

Posted: Tue 01 Nov 2016 15:54
by Pinturiccio
Please describe the issue in more details. What actions do you perform, what result do you expect, and what result do you get?