Skip to content

Latest commit

 

History

History
121 lines (82 loc) · 4.52 KB

entity-framework.md

File metadata and controls

121 lines (82 loc) · 4.52 KB

Entity Framework (EF)

O/RM in .NET Core

What is EF?

  • Object-relational mapper (O/RM)
  • Supports many different DB providers (list)
    examples:
    • MS SQL Server
    • SQLite
    • PostgreSQL
    • MySQL
    • In-Memory (for testing)
  • Latest version: EF Core 3.0
  • NuGet (example): Microsoft.EntityFrameworkCore.SqlServer

Getting Started

Building a Model

<!--#include file="entity-framework/0010-intro/Person.cs" -->

Setting up the Context

<!--#include file="entity-framework/0010-intro/Context.cs" -->

Writing Data

<!--#include file="entity-framework/0010-intro/WriteToDB.cs" -->

Writing Data to Related Sets

<!--#include file="entity-framework/0030-joins/AddingWithJoin.cs" -->
  • Note single call to Add and SaveChangesAsync

Querying Data

<!--#include file="entity-framework/0010-intro/ReadFromDB.cs" -->

Querying Data

<!--#include file="entity-framework/0030-joins/QueryWithJoin.cs" -->
  • Include: Getting Order with related Customer

Learn by Example

EF Core + ASP.NET Core Cheat Sheet

Entity Framework Cheat Sheet

Further Readings and Exercises