linqentity-frameworklinq-to-entitiespartial-trust

Entity Framework in Partial trust environment


I know that Entity Framework supports Partial trust, I personally blogged about that

It was working fine, I tested it and it was fine. Now if you download the samples attached to my post about the subject, it doesn't run under default partial trust anymore!!!

When I dug into System.Data.Entity assembly using reflector on the position of failure "System.Data.Objects.LightweightCodeGenerator.ValidateSetterProperty(RuntimeMethodHandle setterMethodHandle, MethodInfo& setterMethodInfo, Type& realType" I noticed that it calls RuntimeMethodHandle.Value property which has the following attribute on get accessor "[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]"

So I went to my medium trust configuration and added another flag "UnmanagedCode" ""

I test the application again and it worked fine.

Now what is this all about?! It was working before so why now not it is not! There is something missing!!! Does System.Data.Entity changed during the several frequent updates post to of VS.NET 2008 SP1 and the latest one was made on Last August 2009. Because before that date, it was working fine.

So I would appreciate if any could clarify this and guide me if I am wrong, or there is something that I am missing.


Solution

  • Diego Vega PM in Entity Framework team responded to this issue in Entity Framework forums with the following

    Hello Muhammad,

    We are aware of an issue in the build included in Windows 7 and Windows Server 2008 R2 that prevents Entity Framework from working in Medium Trust.

    Both the version of mscoree.dll and the exception message you describe match the scenario.

    We expect to have a solution before mainstream adoption of Windows 7 and Windows Server 2008 R2, but in the meanwhile the recommendation is to keep using Windows Server 2008 or Windows Vista for testing and deploying of EF based applications in Medium Trust.

    Hope this helps, Diego