✅ Is it possible to disable these properties on EF6? Web API 2 project, multi-layered, NF472

SCENARIO
  • Solution type is NET Framework 4.7.2 (it is, what it is).
  • I have this project, I'm consuming theses objects from the DB through EF (data layer), see image 5 . Information goes through to other layers before reaching out to the web API layer,
  • Web API works (image 1), I can make a request and get data back as seen in Postman (image 2) and browser (image 3).
  • I was getting this error https://stackoverflow.com/q/19467673/7389293 which I solved by just using a rough DTO to pass what I get from EF, I'm planning on using AutoMapper down the road.
    QUESTION
  • Is there a way to not generate those public virtual fields on the EF classes? So I can throw the object from the EF right away into the API response.
chrome_6AedDH0N9h.png
Postman_fMMctIbPEd.png
chrome_DG50WnQHzc.png
devenv_sxV0orycRy.png
devenv_r1ZR3m9rF6.png
Stack Overflow
I have a strange error. I'm experimenting with a .NET 4.5 Web API, Entity Framework and MS SQL Server. I've already created the database and set up the correct primary and foreign keys and relation...
Was this page helpful?