开发者

Entity Framework - Medium Trust

开发者 https://www.devze.com 2022-12-22 01:52 出处:网络
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'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, b开发者_开发知识库ut I seem to be running out of options. Any advice greatly appreciated.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消