Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I'm learning Entity Framework, while trying out Database First Approach.
I added an Entity Model to the project and created an API controller using Entity Framework. By just browsing the get method from the API controller Created I found that the data is obtained in json format which is as expected. My table in the database have foreign keys associated with it.
What I found is with reference to the foreign key, json contains the data from the table in consideration also with the data which is in another data linked to this table with foreign key.
I expect only the data from the original table to be returned back and not the data from the foreign table.
Can anyone please provide some pointers to this.
Posted

1 solution

Resolved this by disabling the lazy loading functionality in context class constructor as below,

this.Configuration.LazyLoadingEnabled = false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900