Code-First Development with Entity framework Tutorial

Entity Framework Code First Approach

Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.

  • Develop without ever having to open a designer or define an XML mapping file
  • Define your model objects by simply writing "plain old classes" with no base classes required
  • Use a "convention over configuration" approach that enables database persistence without explicitly configuring anything
  • Optionally override the convention-based persistence and use a fluent code API to fully customize the persistence mapping

Run the following command in the Package Manager Console to migrate the model to the database


update-database -targetmigration:"0" -force -verbose
add-migration Initial
update-database -verbose

Code First Insert/Update/Delete Stored Procedures

DotNetSpeak: Entity Framework Talk at Atlanta Code Camp 2013

Enable-Migrations –EnableAutomaticMigrations

MSDN: Code First Insert/Update/Delete Stored Procedures

MSDN: Configuring Relationships with the Fluent API

Data Developer Center - Entity Framework

Codeplex: EF Open Source

Tutorial series updated for Entity Framework 6 Code First with MVC 5

Models (POCO - Plain Old CLR Objects), Entity Framework and Data Patterns

Code First Insert/Update/Delete Stored Procedures

Codeplex: Multiple Contexts per Database in EF6

EntitiesToDTOs - Entity Framework DTO Generator