问题
I'm trying out EF CodeFirst CTP 5, and using it with WCF Data Services. I'm getting an error that Internal Server Error. The type 'System.Data.Entity.DynamicProxies.Person_C321D7A37002A1B42C3CBAECC27983D77F6B7FCC3F837175B2CBB55CCA66AF55' is not a complex type or an entity type.
If I use an edmx-generated Person off the db created by CF, I have no issue. In reading up, it seems that the lazy loading is screwing things up, and previous EF versions have let me turn off proxy generation with an option flag that's not present in the DbContext. There is a way to set up LazyLoading to false, but that doesn't apparently turn off proxy generation.
Thanks.
回答1:
Here's what you can do in EF code first CTP5:
((IObjectContextAdapter)context).ObjectContext.ContextOptions.ProxyCreationEnabled = false;
Alternatively, this is a bug in WCF data services in VS 2010 RTM. You can used the CTP1 of WCF Data Services that has this issue fixed.
Hope this helps.
Thanks
Pratik
回答2:
In CTP1, the binaries have been renamed to Microsoft.Data.Services.*.dll. Did you change the references to the new assemblies? I am pretty sure that this issue was fixed in CTP1. So just wanted to make sure it worked for you.
Thanks Pratik
回答3:
If you are using the new DbContext class, then you can make use of
Configuration.ProxyCreation = false
To disable the dynamic proxy creation
来源:https://stackoverflow.com/questions/5096680/wcf-entity-framework-codefirst-dynamicproxies-exception