Entity Framework Core (EF Core) is a modern object-database mapper that lets you build a clean, portable, and high-level data access layer with .NET (C#) across a variety of databases, including SQL Server (on-premises and Azure), SQLite, MySQL, PostgreSQL, Oracle, and Azure Cosmos DB. It supports LINQ queries, change tracking, updates, and schema migrations.

Getting started

Prerequisites

Make sure to install the same version of all EF Core packages shipped by Microsoft. For example, if version 5.0.3 of Microsoft.EntityFrameworkCore.SqlServer is installed, then all other Microsoft.EntityFrameworkCore.* packages must also be at 5.0.3.

Usage

To use Microsoft.EntityFrameworkCore in your application, you will typically need to create a class that inherits from DbContext, which represents your database session. You can then define classes that represent your database entities, and use LINQ queries to interact with the database.

Here's an example of how you might define a database context and an entity:

using Microsoft.EntityFrameworkCore;

public class MyDbContext : DbContext
{
    public DbSet<Customer> Customers { get; set; }
}

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
}

You can then use the MyDbContext class to interact with the database:

using var context = new MyDbContext();

// Add a new customer
context.Customers.Add(new Customer { Name = "John Doe" });
context.SaveChanges();

// Retrieve all customers
var customers = context.Customers.ToList();

Microsoft.EntityFrameworkCore supports multiple database providers, including SQL Server, MySQL, PostgreSQL, SQLite, and others. You will need to install the provider package for your chosen database. For example, to use SQL Server, you would install the Microsoft.EntityFrameworkCore.SqlServer package.

You would then configure your database context to use the SQL Server provider:

using Microsoft.EntityFrameworkCore;

public class MyDbContext : DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder options)
        => options.UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=MyDatabase");

    public DbSet<Customer> Customers { get; set; }
}

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Additional documentation

Feedback

If you have a specific question about using these projects, we encourage you to ask it on Stack Overflow. If you encounter a bug or would like to request a feature, submit an Github issue. For more details, see getting support.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 

NuGet packages (10.1K)

Showing the top 5 NuGet packages that depend on Microsoft.EntityFrameworkCore:

Package Downloads
Microsoft.EntityFrameworkCore.Relational

Shared Entity Framework Core components for relational database providers.

Microsoft.EntityFrameworkCore.InMemory

In-memory database provider for Entity Framework Core (to be used for testing purposes).

Npgsql.EntityFrameworkCore.PostgreSQL

PostgreSQL/Npgsql provider for Entity Framework Core.

Microsoft.VisualStudio.Web.CodeGenerators.Mvc

Code Generators for ASP.NET Core MVC. Contains code generators for MVC Controllers and Views.

Microsoft.VisualStudio.Web.CodeGeneration.Design

Code Generation tool for ASP.NET Core. Contains the dotnet-aspnet-codegenerator command used for generating controllers and views.

GitHub repositories (679)

Showing the top 20 popular GitHub repositories that depend on Microsoft.EntityFrameworkCore:

Repository Stars
abpframework/abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.

kgrzybek/modular-monolith-with-ddd

Full Modular Monolith application with Domain-Driven Design approach.

dotnet/AspNetCore.Docs

Documentation for ASP.NET Core

aspnetboilerplate/aspnetboilerplate

ASP.NET Boilerplate - Web Application Framework

dodyg/practical-aspnetcore

Practical samples of ASP.NET Core 10, 9, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.

davidfowl/AspNetCoreDiagnosticScenarios

This repository has examples of broken patterns in ASP.NET Core applications

RayWangQvQ/BiliBiliToolPro

B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。敏感肌也能用。

btcpayserver/btcpayserver

Accept Bitcoin payments. Free, open-source & self-hosted, Bitcoin payment processor.

EduardoPires/EquinoxProject

Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices

fullstackhero/dotnet-starter-kit

Production Grade Cloud-Ready .NET 10 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.

ldqk/Masuit.Tools

全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!

graphql-dotnet/graphql-dotnet

GraphQL for .NET

danielgerlag/workflow-core

Lightweight workflow engine for .NET Standard

ChilliCream/graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.

DearVa/Everywhere

Context-aware AI assistant for your desktop. Ready to respond intelligently, seamlessly integrating multiple LLMs and MCP tools.

jasontaylordev/NorthwindTraders

Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.

immense/Remotely

A remote control and remote scripting solution, built with .NET 8, Blazor, and SignalR.

MapsterMapper/Mapster

A fast, fun and stimulating object to object Mapper

microsoft/fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications

dotnetcore/Util

Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。

Version Downloads Last Updated
11.0.0-preview.1.26104.118 3,383 2/10/2026
10.0.3 675,532 2/10/2026
10.0.2 3,559,436 1/13/2026
10.0.1 4,018,514 12/9/2025
10.0.0 7,519,203 11/11/2025
10.0.0-rc.2.25502.107 485,954 10/14/2025
10.0.0-rc.1.25451.107 190,915 9/9/2025
10.0.0-preview.7.25380.108 58,113 8/12/2025
9.0.13 132,393 2/10/2026
9.0.12 902,393 1/13/2026
9.0.11 4,113,350 11/11/2025
9.0.10 7,391,644 10/14/2025
9.0.9 10,066,250 9/9/2025
9.0.8 9,183,324 8/5/2025
8.0.24 137,138 2/10/2026
8.0.23 729,400 1/13/2026
8.0.22 3,120,754 11/11/2025
8.0.21 2,080,825 10/14/2025
8.0.20 2,866,113 9/9/2025
8.0.19 4,151,798 8/5/2025