[英]Entity Framework WebAPI: Code first returns json correctly, DB first only returns first object and references for others
i am moving a Code first EF project to a DB first project, cause we need to add our project to an existing DB and use some of the existing tables. 我将代码优先EF项目移至数据库优先项目,因为我们需要将我们的项目添加到现有数据库并使用一些现有表。
when i run the CodeFirst project it returns the correct JSON: 当我运行CodeFirst项目时,它返回正确的JSON:
, but when i do the same on the DB first project it only returns the first object, and returns $refs for all the other objects. ,但是当我在DB第一个项目上执行相同操作时,它仅返回第一个对象,并为所有其他对象返回$ refs。
You will need to make use of DTO's to transfer your data from your web api to the client application. 您将需要使用DTO将数据从Web api传输到客户端应用程序。
Those references are proxies for entity framework, to lazyload these but they don't get serialized in json. 这些引用是实体框架的代理,可以延迟加载它们,但不会在json中序列化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.