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="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Application.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" 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.
精彩评论