38 Entity Framework Core

What’s In This Chapter?

  • Introducing Entity Framework Core 1.0
  • Using Dependency Injection with Entity Framework
  • Creating a Model with Relations
  • Using Migrations with the .NET CLI Tools and MSBuild
  • Object Tracking
  • Updating Objects and Object Trees
  • Conflict Handling with Updates
  • Using Transactions

Wrox.Com Code Downloads For This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/ professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • Books Sample
  • Books Sample with DI
  • Menus Sample
  • Menus with Data Annotations
  • Conflict Handling Sample
  • Transactions Sample

History of Entity Framework

Entity Framework is a framework offering mapping of entities to relationships. With this, you can create types that map to database tables, create database queries using LINQ, create and update objects, and write them to the database.

After many years of few changes to Entity Framework, the newest version is a complete rewrite. Let’s have a look at the history of Entity Framework to see the reasons for the rewrite.

  • Entity Framework 1—The first version of Entity Framework was not ready with .NET 3.5, but it was soon available with .NET 3.5 SP1. Another product offering somewhat similar functionality that was already available with .NET 3.5 was LINQ to SQL. Both LINQ to SQL and Entity Framework offered similar features from a wide view. However, LINQ to SQL was simpler to use but ...

Get Professional C# 6 and .NET Core 1.0 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.