msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
119 stars 21 forks source link

Not mapped issue #17

Closed saigkill closed 1 year ago

saigkill commented 2 years ago

I have the following case: I have a BaseEntity where all other Entity derive from. Inside that i have some standard things defined, like ID, Created and Modified. Currently i solved that case by adding a custom atribute "NotMapped" to the BaseEntity class. After gerneration was the BaseEntity in DBSet and modelBuilder from the context. Can this be fixed?

msawczyn commented 2 years ago

This is one that I've had on my plate for some time now.

I've added a "Persistent" property (defaults to true) to the class. Setting it to "false" will, after validating that it's allowed to become a transient class, cause code generation to do the things you're looking for.

Paying attention to the attributes becomes a slippery slope, since there's an uncountable number of possibilities, so supporting this with its own property helps limit that and allows the modeler to provide some assistance to folks who might try adding a transient class in the middle of an inheritance hierarchy (the tool prevents that since it causes all sorts of chaos).

Thanks for the report! It'll be in 4.2.