I am creating a new .NET Core application with the following components:
- .NET Core 3.0 Web API for apis
- .NET Core Razor pages for the web UI
- .NET Core class libraries - one for utilities and one for the model
I am using Entity Framework core for the model. I generally hate ORM tools but time is critical for this project so I don't have much choice. I have to say that, all things considered, it is pretty darn solid.
One of the issues I had is that I had to decorate some of my model's properties with the JsonIgnore attribute, e.g. :
[JsonIgnore]
public virtual ICollection<LabOrder> LabOrders { get; set; }
The reason for that is that otherwise, when I serialize the object (in order to return it from an api) .NET throws the exception about too many nested levels or whatever because of parent-child-back-to-parent relationships that would cause a never-ending recursion to happen. So, all fine and dandy, the JsonIgnore attribute did just what I need.
BUT, here is my issue. I've gone through the trouble of decorating these properties everywhere I need to, and completed a first round of development and testing. I need to make some adjustments to my database model; which I've done... and now it is time to refresh the EF Core dbcontext. When creating new properties or methods I can use partial classes to retain any "custom" changes I make to the model, but I have no idea how I might accomplish that here.
So: Is it possible for one to retain my property decorations and still use the Scaffold-dbcontext command to refresh the model? I've used that command successfully in the past, but now I need to make sure I somehow don't lose my changes.