简体   繁体   中英

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.

when i run the CodeFirst project it returns the correct JSON:

correctJson

, 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.

badJson

You will need to make use of DTO's to transfer your data from your web api to the client application.

Those references are proxies for entity framework, to lazyload these but they don't get serialized in json.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM