Entity Framework in Class Library without colliding with client EF versions

0

I implemented a custom .NET RoleProvider as a class library project using Entity Framework. This is to be used with multiple web applications. How do I keep the EF used by the .dll from colliding with any EF version used by the client web application?

This class library references EF6. When I compile it, I get the library .dll, along with the EF6 EntityFramework.dll and EntityFramework.SqlServer.dll files. This works fine in web applications that either don't reference EF at all, or happen to reference the same version of EF6- I can put all three files in the bin folder of the web application. However, if I reference my role provider in a web forms project that also references EF5, that means the two EF5 .dll files are already in the bin folder for the web app, so I can't put the same-named EF6 .dll files in there. If I put only my custom .dll in there it won't compile and complains about loading my assembly while parsing the web.config file (where the role provider is configured).

=== Pre-bind state information ===
LOG: DisplayName = EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///D:/OVPR_Apps/A/Intramural/
LOG: Initial PrivatePath = D:\OVPR_Apps\A\Intramural\bin
Calling assembly : OVPRRoleProvider, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null.
===
...
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Is there a way to encapsulate the required EF library versions with my own .dll? Or to otherwise isolate whatever my .dll needs from the web application it's being used in? I've considered putting the role provider .dll in the GAC anyway, since it's to be used for multiple applications on the server, but I'm reading some red flags about that (strongly name assemblies are bad, etc). I could put EF6 in the GAC as well, but it seems like I shouldn't be forced to go the GAC route just because of EF.

c#
.net
entity-framework
dll
class-library
asked on Stack Overflow May 2, 2019 by esanford

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0