Since you expressly declare that you are creating a very simple web API project, you can leave with a simple global replacement. Although I converted the project to use ASP.NET web APIs, I ran into the same problem. Since I regularly changed the database schema, it was just easier to return the original types, rather than dynamic or strongly typed view models, because the properties of the data that was wrapped were constantly changing.
Properties that must be ignored for serialization are all navigation properties created by EF. It also happens that all these properties are virtual. I made a replacement in the files (only for my data library project), replacing all public virtual with [Newtonsoft.Json.JsonIgnore] public virtual .
A quick and easy fix that allows you to test while the project is still in development. I agree that, in the end, you should probably migrate EF models to view models, but this simple way allows you to continue to work without them a little more.
source share