views:

209

answers:

3

I'm trying to get the entity framework working in medium trust. I've tried splitting the files and using a separate assembly but I seem to have one problem after another.

I moved the EDMX to a separate assembly, which causes a single .dll to be outpit to the sites /Bin directory. I'm referencing this as below from web.config.

<add name="ApplicationDB" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Application.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="ShopEntities" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Application.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

Whenever I try to access one of the entity classes, I get an ArgumentException: 'An item with the same key has already been added.' It's critical this works with medium trust, but I seem to be running out of options. Any advice greatly appreciated.

A: 

You. Are. Done.

Does not work. Point.

Dont. use. That. Crap. Comes to my mind. EF 2 (.NET 4.0) is "BAD", but EF 1 (.NET 3.5) is total utter crap.

Medium trust - not supported scenario. Someone should have thought about that before starting programming. Checking requirements phase. No way to get it working (unless you "open up" medium trust, but then it is not medium trust anymore anyway).

TomTom
Thanks. It's really critical that this works you see, as huge amounts of time have been invested.
Echilon
Sorry, where does it say that EF isn't supported under Medium Trust? I've had it running under the default medium trust for at least a year.
Zhaph - Ben Duguid
+1  A: 

You can use Entity Framework 3.5 in medium trust. However, there is a problem with running this on Windows 7 and Windows Server 2008. Microsoft released a patch for this. Read here for more info.

Steven
+1  A: 

Moving the EDMX and all partial classes to a separate assembly was the eventual solution.

Echilon