delirek
delirek

Reputation: 70

Entity Framework 5 and 6 in the same application

I want to use different version of Entity Framework in the same project.? I have two appication: -one with EF5 -and the second with EF6 and reference to first project(those one with ef5)

Now i want to use methods from the first one in the second one. But....

i have problems, with this ,cause when i run method from ef5 app, it says that :

Could not load file or assembly 'EntityFramework, Version = 5.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089' or one of its dependencies. Located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

How to use different version of EF dll in the same project?

suggesions?Thanx.

Upvotes: 1

Views: 3300

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364369

You cannot load multiple versions of the same assembly into single Application domain. .NET Framework does not support it. You must either use:

  • Use single version of EF in both "applications" - this should be the right way to go if you need to use EF dependent code from the first application in the second one
  • Refactor first application and move all methods you need to reuse into separate assembly not dependent on EF - this should be the right way to go if you can abstract the code from EF
  • Execute code from the first application in separate application domain - don't use this approach. It is like running two ".NET processes" in a single windows process. You have to use inter-process communication to pass data between two application domains.

Normally there is also option for binding redirects but I'm afraid it will not work in this case because EF6 brings too many breaking changes.

Upvotes: 4

Related Questions