Things to note

Image

Image The OnModelCreating() method is a member of the DbContext class, so if you’ve separated your context class from your (code-only) entity classes, that distinction remains pure.

Image Although you can use DbModelBuilder independently, overriding OnModelCreating() is the most common and recommended approach. When you create the override, Intellisense will add the base call for you.

The DbModelBuilder exposes a couple of properties and methods ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.