Pros and cons for Entity Framework Code-First

Source: http://stackoverflow.com/questions/3330202/entity-framework-4-code-first-pros-and-cons

Pros:

Lightweight entity classes or POCO based.

More control over entity classes since you code them yourself rather than depending on EF to generate them. This means you don’t have to define partial classes to do data annotations.

Option to never have to specify mapping anywhere. Convention takes over configuration.

DbContext follows the repository pattern.

Lazy loading, related entity loading all taken care of for you. For example a Post model can declare Author model in the POCO and EF Code first will map this relation automatically. Again use of convention makes us so productive.

Works great for greenfield applications.

ASP.NET MVC view generation works great.

ModelBinder works as per normal.

Cons:

No API support for customizing the database mapping convention like in Fluent nHibernate.Bit difficult to map to existing databases.(This might change in the release version).

Advertisements

One thought on “Pros and cons for Entity Framework Code-First

  1. Interesting, I find it quite simple to map to existing database. Furthermore, there are tools which generate the DbContext from an existing database, they greatly speed up the process of creating the DbContext and they reduce errors.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s