The fluent API

Image

Data annotations are simple to use, but once you start adding information about how your classes map to the database they can no longer really claim to be persistence-ignorant. They can also get a little unwieldy—I’ve seen classes that had more metadata than code. The second method Entity Framework provides for customizing the model, the Fluent API, provides an alternative that is completely code-based and lets you confine all your database-related code to the context class.

The Entity Framework Fluent API is an example of a technique known as a FLUENT INTERFACE. (Neither has any relationship to the Fluent Learning series of which ...

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.