Microsoft.EntityFrameworkCore 9.0.4

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.

Requires NuGet 3.6 or higher.

dotnet add package Microsoft.EntityFrameworkCore --version 9.0.4
                    
NuGet\Install-Package Microsoft.EntityFrameworkCore -Version 9.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.EntityFrameworkCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.EntityFrameworkCore --version 9.0.4
                    
#r "nuget: Microsoft.EntityFrameworkCore, 9.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.4
                    
Install Microsoft.EntityFrameworkCore as a Cake Addin
#tool nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.4
                    
Install Microsoft.EntityFrameworkCore as a Cake Tool

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 net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8.8K)

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.EntityFrameworkCore.Proxies

Lazy loading proxies for Entity Framework Core.

Microsoft.AspNetCore.App

Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.

GitHub repositories (625)

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

Repository Stars
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
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.
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
kgrzybek/modular-monolith-with-ddd
Full Modular Monolith application with Domain-Driven Design approach.
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 10 Preview 3, 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
elsa-workflows/elsa-core
A .NET workflows library
louthy/language-ext
C# pure functional programming framework - come and get declarative!
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
graphql-dotnet/graphql-dotnet
GraphQL for .NET
ldqk/Masuit.Tools
全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 9 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
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.
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.
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
MapsterMapper/Mapster
A fast, fun and stimulating object to object Mapper
Version Downloads Last updated
10.0.0-preview.3.25171.6 2,825 4/10/2025
10.0.0-preview.2.25163.8 10,453 3/18/2025
10.0.0-preview.1.25081.1 11,545 2/25/2025
9.0.4 399,200 4/8/2025
9.0.3 3,510,755 3/11/2025
9.0.2 3,840,850 2/11/2025
9.0.1 5,743,775 1/14/2025
9.0.0 10,923,303 11/12/2024
9.0.0-rc.2.24474.1 193,099 10/8/2024
9.0.0-rc.1.24451.1 124,334 9/10/2024
9.0.0-preview.7.24405.3 80,949 8/13/2024
9.0.0-preview.6.24327.4 120,379 7/9/2024
9.0.0-preview.5.24306.3 44,242 6/11/2024
9.0.0-preview.4.24267.1 58,518 5/21/2024
9.0.0-preview.3.24172.4 171,953 4/11/2024
9.0.0-preview.2.24128.4 67,588 3/12/2024
9.0.0-preview.1.24081.2 104,628 2/13/2024
8.0.15 135,599 4/8/2025
8.0.14 1,196,674 3/11/2025
8.0.13 2,131,057 2/11/2025
8.0.12 2,714,748 1/14/2025
8.0.11 12,114,296 11/12/2024
8.0.10 17,047,755 10/8/2024
8.0.8 22,005,226 8/13/2024
8.0.7 14,011,254 7/9/2024
8.0.6 16,187,255 5/28/2024
8.0.5 6,994,644 5/14/2024
8.0.4 25,738,199 4/9/2024
8.0.3 10,859,527 3/12/2024
8.0.2 21,094,998 2/13/2024
8.0.1 13,827,747 1/9/2024
8.0.0 40,287,745 11/14/2023
8.0.0-rc.2.23480.1 517,389 10/10/2023
8.0.0-rc.1.23419.6 144,097 9/12/2023
8.0.0-preview.7.23375.4 114,059 8/8/2023
8.0.0-preview.6.23329.4 195,957 7/11/2023
8.0.0-preview.5.23280.1 176,201 6/13/2023
8.0.0-preview.4.23259.3 135,175 5/16/2023
8.0.0-preview.3.23174.2 225,912 4/11/2023
8.0.0-preview.2.23128.3 195,145 3/14/2023
8.0.0-preview.1.23111.4 138,725 2/21/2023
7.0.20 3,115,571 5/28/2024
7.0.19 499,860 5/14/2024
7.0.18 2,175,780 4/9/2024
7.0.17 1,580,597 3/12/2024
7.0.16 2,016,424 2/13/2024
7.0.15 3,146,424 1/9/2024
7.0.14 5,957,285 11/14/2023
7.0.13 6,597,498 10/24/2023
7.0.12 4,359,189 10/10/2023
7.0.11 13,334,958 9/12/2023
7.0.10 9,540,695 8/8/2023
7.0.9 8,890,064 7/11/2023
7.0.8 5,430,554 6/22/2023
7.0.7 3,735,249 6/13/2023
7.0.5 25,295,171 4/11/2023
7.0.4 9,334,196 3/14/2023
7.0.3 13,644,902 2/14/2023
7.0.2 18,514,851 1/10/2023
7.0.1 9,931,196 12/13/2022
7.0.0 29,452,058 11/7/2022
7.0.0-rc.2.22472.11 219,231 10/11/2022
7.0.0-rc.1.22426.7 213,842 9/14/2022
7.0.0-preview.7.22376.2 97,823 8/9/2022
7.0.0-preview.6.22329.4 76,586 7/12/2022
7.0.0-preview.5.22302.2 64,806 6/14/2022
7.0.0-preview.4.22229.2 84,266 5/10/2022
7.0.0-preview.3.22175.1 78,591 4/13/2022
7.0.0-preview.2.22153.1 86,072 3/14/2022
7.0.0-preview.1.22076.6 58,266 2/17/2022
6.0.36 939,277 11/12/2024
6.0.35 581,322 10/8/2024
6.0.33 1,574,554 8/13/2024
6.0.32 732,889 7/9/2024
6.0.31 1,015,339 5/28/2024
6.0.30 537,954 5/14/2024
6.0.29 2,557,915 4/9/2024
6.0.28 1,499,054 3/12/2024
6.0.27 1,797,038 2/13/2024
6.0.26 2,566,474 1/9/2024
6.0.25 3,545,174 11/14/2023
6.0.24 1,844,972 10/24/2023
6.0.23 1,218,459 10/10/2023
6.0.22 3,313,301 9/12/2023
6.0.21 3,513,756 8/8/2023
6.0.20 2,821,668 7/11/2023
6.0.19 2,369,390 6/22/2023
6.0.18 1,261,592 6/13/2023
6.0.16 7,452,106 4/11/2023
6.0.15 4,122,744 3/14/2023
6.0.14 5,223,908 2/14/2023
6.0.13 6,856,099 1/10/2023
6.0.12 10,691,507 12/13/2022
6.0.11 9,804,210 11/7/2022
6.0.10 17,317,234 10/11/2022
6.0.9 15,141,750 9/13/2022
6.0.8 18,209,782 8/9/2022
6.0.7 49,187,005 7/12/2022
6.0.6 14,615,377 6/14/2022
6.0.5 22,294,493 5/10/2022
6.0.4 17,770,613 4/11/2022
6.0.3 24,386,241 3/8/2022
6.0.2 19,619,351 2/8/2022
6.0.1 32,493,377 12/14/2021
6.0.0 67,706,334 11/8/2021
6.0.0-rc.2.21480.5 324,442 10/12/2021
6.0.0-rc.1.21452.10 266,238 9/14/2021
6.0.0-preview.7.21378.4 97,215 8/10/2021
6.0.0-preview.6.21352.1 43,713 7/14/2021
6.0.0-preview.5.21301.9 187,192 6/15/2021
6.0.0-preview.4.21253.1 72,788 5/24/2021
6.0.0-preview.3.21201.2 96,960 4/8/2021
6.0.0-preview.2.21154.2 73,050 3/11/2021
6.0.0-preview.1.21102.2 96,063 2/12/2021
5.0.17 7,633,176 5/10/2022 5.0.17 is deprecated because it is no longer maintained.
5.0.16 1,493,817 4/11/2022 5.0.16 is deprecated because it is no longer maintained.
5.0.15 2,334,040 3/8/2022 5.0.15 is deprecated because it is no longer maintained.
5.0.14 2,355,023 2/8/2022 5.0.14 is deprecated because it is no longer maintained.
5.0.13 4,445,785 12/14/2021 5.0.13 is deprecated because it is no longer maintained.
5.0.12 4,829,838 11/7/2021 5.0.12 is deprecated because it is no longer maintained.
5.0.11 8,394,106 10/12/2021 5.0.11 is deprecated because it is no longer maintained.
5.0.10 13,398,319 9/14/2021 5.0.10 is deprecated because it is no longer maintained.
5.0.9 10,296,954 8/10/2021 5.0.9 is deprecated because it is no longer maintained.
5.0.8 9,595,349 7/13/2021 5.0.8 is deprecated because it is no longer maintained.
5.0.7 14,385,322 6/8/2021 5.0.7 is deprecated because it is no longer maintained.
5.0.6 8,189,126 5/11/2021 5.0.6 is deprecated because it is no longer maintained.
5.0.5 11,416,747 4/6/2021 5.0.5 is deprecated because it is no longer maintained.
5.0.4 8,279,238 3/9/2021 5.0.4 is deprecated because it is no longer maintained.
5.0.3 8,073,069 2/9/2021 5.0.3 is deprecated because it is no longer maintained.
5.0.2 10,521,617 1/12/2021 5.0.2 is deprecated because it is no longer maintained.
5.0.1 15,929,207 12/8/2020 5.0.1 is deprecated because it is no longer maintained.
5.0.0 26,647,517 11/9/2020 5.0.0 is deprecated because it is no longer maintained.
5.0.0-rc.2.20475.6 380,362 10/13/2020
5.0.0-rc.1.20451.13 318,855 9/14/2020
5.0.0-preview.8.20407.4 202,894 8/25/2020
5.0.0-preview.7.20365.15 114,725 7/21/2020
5.0.0-preview.6.20312.4 63,936 6/25/2020
5.0.0-preview.5.20278.2 49,533 6/10/2020
5.0.0-preview.4.20220.10 73,849 5/18/2020
5.0.0-preview.3.20181.2 94,706 4/23/2020
5.0.0-preview.2.20159.4 61,689 4/2/2020
5.0.0-preview.2.20120.8 46,112 3/16/2020
3.1.32 5,644,848 12/13/2022
3.1.31 1,100,577 11/8/2022
3.1.30 741,451 10/11/2022
3.1.29 1,281,309 9/13/2022
3.1.28 848,368 8/9/2022
3.1.27 748,593 7/12/2022
3.1.26 653,793 6/14/2022
3.1.25 1,091,832 5/10/2022
3.1.24 657,530 4/11/2022
3.1.23 1,070,331 3/8/2022
3.1.22 3,441,218 12/14/2021
3.1.21 2,639,040 11/7/2021
3.1.20 1,575,747 10/11/2021
3.1.19 2,478,613 9/14/2021
3.1.18 5,307,858 8/10/2021
3.1.17 1,897,823 7/13/2021
3.1.16 2,391,681 6/8/2021
3.1.15 2,852,611 5/11/2021
3.1.14 3,124,259 4/6/2021
3.1.13 4,622,816 3/9/2021
3.1.12 3,017,211 2/9/2021
3.1.11 5,470,282 1/12/2021
3.1.10 8,364,889 11/9/2020
3.1.9 12,067,517 10/13/2020
3.1.8 17,746,879 9/8/2020
3.1.7 10,106,344 8/11/2020
3.1.6 10,821,136 7/14/2020
3.1.5 12,879,113 6/9/2020
3.1.4 17,986,489 5/12/2020
3.1.3 28,058,592 3/24/2020
3.1.2 11,951,740 2/19/2020
3.1.1 20,061,152 1/14/2020
3.1.0 34,355,689 12/3/2019
3.1.0-preview3.19554.8 164,784 11/13/2019
3.1.0-preview2.19525.5 32,751 11/1/2019
3.1.0-preview1.19506.2 761,744 10/15/2019
3.0.3 189,837 2/19/2020
3.0.2 80,224 1/14/2020
3.0.1 1,406,001 11/18/2019
3.0.0 19,084,391 9/23/2019
3.0.0-rc1.19456.14 46,723 9/16/2019
3.0.0-preview9.19423.6 1,381,535 9/4/2019
3.0.0-preview8.19405.11 412,689 8/13/2019
3.0.0-preview7.19362.6 90,635 7/23/2019
3.0.0-preview6.19304.10 168,100 6/12/2019
3.0.0-preview5.19227.1 671,724 5/6/2019
3.0.0-preview4.19216.3 23,015 4/18/2019
3.0.0-preview3.19153.1 202,355 3/6/2019
3.0.0-preview.19074.3 31,664 1/29/2019
3.0.0-preview.18572.1 48,596 12/3/2018
2.3.0 10,565 1/14/2025
2.2.6 31,773,513 7/9/2019 2.2.6 is deprecated because it is no longer maintained.
2.2.4 19,554,330 4/9/2019 2.2.4 is deprecated because it is no longer maintained.
2.2.3 5,340,619 3/11/2019 2.2.3 is deprecated because it is no longer maintained.
2.2.2 6,437,898 2/12/2019 2.2.2 is deprecated because it is no longer maintained.
2.2.1 6,894,657 1/8/2019 2.2.1 is deprecated because it is no longer maintained.
2.2.0 21,727,107 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 184,872 10/17/2018
2.2.0-preview2-35157 149,105 9/12/2018
2.2.0-preview1-35029 82,290 8/22/2018
2.1.14 3,972,731 11/18/2019
2.1.11 3,699,906 5/14/2019
2.1.8 3,762,349 2/12/2019
2.1.4 15,556,442 10/1/2018
2.1.3 4,892,779 9/11/2018
2.1.2 8,107,939 8/21/2018
2.1.1 16,386,334 6/18/2018
2.1.0 13,275,072 5/29/2018
2.1.0-rc1-final 224,340 5/6/2018
2.1.0-preview2-final 205,420 4/10/2018
2.1.0-preview1-final 316,762 2/26/2018
2.0.3 5,344,294 5/7/2018 2.0.3 is deprecated because it is no longer maintained.
2.0.2 6,676,390 3/13/2018 2.0.2 is deprecated because it is no longer maintained.
2.0.1 12,519,054 11/14/2017 2.0.1 is deprecated because it is no longer maintained.
2.0.0 27,291,714 8/11/2017 2.0.0 is deprecated because it is no longer maintained.
2.0.0-preview2-final 96,133 6/28/2017 2.0.0-preview2-final is deprecated because it is no longer maintained.
2.0.0-preview1-final 1,118,524 5/10/2017 2.0.0-preview1-final is deprecated because it is no longer maintained.
1.1.6 5,865,702 7/10/2018 1.1.6 is deprecated because it is no longer maintained.
1.1.5 1,247,767 12/12/2017 1.1.5 is deprecated because it is no longer maintained.
1.1.4 224,300 11/14/2017 1.1.4 is deprecated because it is no longer maintained.
1.1.3 308,254 9/20/2017 1.1.3 is deprecated because it is no longer maintained.
1.1.2 5,013,431 5/9/2017 1.1.2 is deprecated because it is no longer maintained.
1.1.1 3,187,216 3/6/2017 1.1.1 is deprecated because it is no longer maintained.
1.1.0 7,305,287 11/16/2016 1.1.0 is deprecated because it is no longer maintained.
1.1.0-preview1-final 46,543 10/24/2016 1.1.0-preview1-final is deprecated because it is no longer maintained.
1.0.6 54,813 11/14/2017 1.0.6 is deprecated because it is no longer maintained.
1.0.5 43,188 9/20/2017 1.0.5 is deprecated because it is no longer maintained.
1.0.4 57,859 5/9/2017 1.0.4 is deprecated because it is no longer maintained.
1.0.3 652,736 3/6/2017 1.0.3 is deprecated because it is no longer maintained.
1.0.2 78,362 12/12/2016 1.0.2 is deprecated because it is no longer maintained.
1.0.1 792,922 9/13/2016 1.0.1 is deprecated because it is no longer maintained.
1.0.0 1,761,071 6/27/2016 1.0.0 is deprecated because it is no longer maintained.
1.0.0-rc2-final 140,587 5/16/2016 1.0.0-rc2-final is deprecated because it is no longer maintained.