Configure scaffolded models via Data Annotations when using the Database First approach in Entity Framework Core

FYI… when using the Database First approach with Entity Framework Core if we choose we can have EF configure the generated models via Data Annotations rather than Fluent API…

Click on the image for a larger view in a new tab…

Which approach to use is a matter of personal or team preference. When we are using the DB first workflow we will never be changing the autogenerated models anyhow so it doesn’t really matter where models are configured.

Unfortunately at the time of writing not all configuration is possible via the annotation approach but the gap is closing with every release.

Leave a Reply

Your email address will not be published. Required fields are marked *