Should there be an EF5 folder / dll

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
ACassells
Posts: 4
Joined: Fri 05 Apr 2013 15:36

Should there be an EF5 folder / dll

Post by ACassells » Fri 05 Apr 2013 15:58

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.

ACassells
Posts: 4
Joined: Fri 05 Apr 2013 15:36

Re: Should there be an EF5 folder / dll

Post by ACassells » Mon 08 Apr 2013 10:46

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?

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

Re: Should there be an EF5 folder / dll

Post by Shalex » Mon 08 Apr 2013 13:23

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>

ACassells
Posts: 4
Joined: Fri 05 Apr 2013 15:36

Re: Should there be an EF5 folder / dll

Post by ACassells » Mon 08 Apr 2013 15:00

Brilliant, thank you for that.

jazz albert
Posts: 1
Joined: Thu 27 Oct 2016 21:27

Re: Should there be an EF5 folder / dll

Post by jazz albert » Thu 27 Oct 2016 21:33

I messed up with aforementioned script and unable to get it out?
infantigoPiercingHealth
Last edited by jazz albert on Tue 07 Feb 2017 22:49, edited 1 time in total.

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Should there be an EF5 folder / dll

Post by Pinturiccio » Tue 01 Nov 2016 15:54

Please describe the issue in more details. What actions do you perform, what result do you expect, and what result do you get?

Post Reply