您的位置:首页 > 编程语言 > ASP

System.Data.Entity.DynamicProxies……不能序列化

2014-06-10 17:53 344 查看
问题:

序列化时,返回错误:类型为“System.Data.Entity.DynamicProxies.……………………………………………………”的对象不能序列化

 

解决方案:

EF的DBContext做如下设置:

dbContext.Configuration.ProxyCreationEnabled = 
false
;


 

参考:


DbContext.Configuration:


http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.configuration(v=vs.113).aspx


DbContextConfiguration:


http://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.dbcontextconfiguration(v=vs.113).aspx



LazyLoadingEnabledGets or sets a value indicating whether lazy loading of relationships exposed as navigation properties is enabled. Lazy loading is enabled by default.

ProxyCreationEnabledGets or sets a value indicating whether or not the framework will create instances of dynamically generated proxy classes whenever it creates an instance of an entity type. Note that even if proxy creation is enabled with this flag, proxy instances
will only be created for entity types that meet the requirements for being proxied. Proxy creation is enabled by default.
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ASP.NET EF web api 序列化
相关文章推荐