问题描述
我正在试用EF CodeFirst CTP 5,并将其与WCF数据服务一起使用。我收到的错误是内部服务器错误。类型'System.Data.Entity.DynamicProxies.Person_C321D7A37002A1B42C3CBAECC27983D77F6B7FCC3F837175B2CBB55CCA66AF55'不是复杂类型或实体类型。
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.
如果我使用edm生成的人关闭由CF创建的数据库,我没有问题。在阅读过程中,似乎延迟加载正在搞砸,并且以前的EF版本让我使用DbContext中不存在的选项标志来关闭代理生成。有一种方法可以将LazyLoading设置为false,但是显然不会关闭代理生成。
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.
谢谢。
推荐答案
您可以在EF代码中首先执行CTP5:
Here's what you can do in EF code first CTP5:
((IObjectContextAdapter)context).ObjectContext.ContextOptions.ProxyCreationEnabled = false;
或者,这是VS 2010 RTM中WCF数据服务中的错误。您可以使用具有已解决。
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.
希望有帮助。
谢谢
Pratik
Hope this helps.
Thanks
Pratik
这篇关于WCF +实体框架CodeFirst = DynamicProxies异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!