Entity Framework 5 "Magic Unicorn"

Sunday, September 15, 2013

Object Relational Mapper ORM

Developer Productivity

Consistent Query Syntax with Linq to Entities!

Features:

  1. Focus on domain and not DB, connections, commands
  2. Customize Mappings, map single entity to multiple database tables
  3. Map multiple entities to a single table
  4. Recommenden data access technology for new applications
  5. Entity Framework is where all forward moving investment from Microsoft is being made
  6. Recommend to use Entity Framework over ADO.NET or Linq to Sql for all new development
  7. Open Source Product
  8. DB First, Model First or Code First

Database first: Model generated in designer from database


Model first: start with an empty model


Generate database from model


Code first

  • Domain Classes
  • Custom Configuration
  • DBContext Model Builder
  • Database Initialization & Migration


DbContext and DbSet


Database automatically created in SQL Server



Adding new property to a user defined type


Enable Migrations in PM console


Creates Migration folder with Containing Configuration class



Database Initialization, Migration strategies

  • CreateDatabaseIfNotExists
  • DropCreateDatabaseIfModelChanges
  • DropCreateDatabaseAlways
  • MigrateDatabaseToLatestVersion

Default Success Warning Important Info Inverse
B S W I ? O