Microsoft.EntityFrameworkCore 9.0.2

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.2                
NuGet\Install-Package Microsoft.EntityFrameworkCore -Version 9.0.2                
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.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.EntityFrameworkCore --version 9.0.2                
#r "nuget: Microsoft.EntityFrameworkCore, 9.0.2"                
#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.
// Install Microsoft.EntityFrameworkCore as a Cake Addin
#addin nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.2

// Install Microsoft.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.2                

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.6K)

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 (609)

Showing the top 5 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.
Version Downloads Last updated
10.0.0-preview.1.25081.1 0 2/25/2025
9.0.2 578,212 2/11/2025
9.0.1 2,004,260 1/14/2025
9.0.0 6,420,035 11/12/2024
9.0.0-rc.2.24474.1 168,614 10/8/2024
9.0.0-rc.1.24451.1 113,247 9/10/2024
9.0.0-preview.7.24405.3 69,235 8/13/2024
9.0.0-preview.6.24327.4 82,404 7/9/2024
9.0.0-preview.5.24306.3 38,163 6/11/2024
9.0.0-preview.4.24267.1 54,333 5/21/2024
9.0.0-preview.3.24172.4 164,904 4/11/2024
9.0.0-preview.2.24128.4 61,255 3/12/2024
9.0.0-preview.1.24081.2 91,572 2/13/2024
8.0.13 314,506 2/11/2025
8.0.12 1,170,698 1/14/2025
8.0.11 6,934,475 11/12/2024
8.0.10 12,548,037 10/8/2024
8.0.8 17,927,173 8/13/2024
8.0.7 11,853,170 7/9/2024
8.0.6 14,078,027 5/28/2024
8.0.5 6,168,499 5/14/2024
8.0.4 22,172,217 4/9/2024
8.0.3 9,689,720 3/12/2024
8.0.2 18,216,754 2/13/2024
8.0.1 12,327,181 1/9/2024
8.0.0 33,987,875 11/14/2023
8.0.0-rc.2.23480.1 490,235 10/10/2023
8.0.0-rc.1.23419.6 140,078 9/12/2023
8.0.0-preview.7.23375.4 107,282 8/8/2023
8.0.0-preview.6.23329.4 179,979 7/11/2023
8.0.0-preview.5.23280.1 140,332 6/13/2023
8.0.0-preview.4.23259.3 129,406 5/16/2023
8.0.0-preview.3.23174.2 205,725 4/11/2023
8.0.0-preview.2.23128.3 192,203 3/14/2023
8.0.0-preview.1.23111.4 137,022 2/21/2023
7.0.20 2,448,443 5/28/2024
7.0.19 451,854 5/14/2024
7.0.18 1,910,809 4/9/2024
7.0.17 1,481,514 3/12/2024
7.0.16 1,897,389 2/13/2024
7.0.15 2,970,316 1/9/2024
7.0.14 5,647,164 11/14/2023
7.0.13 6,168,634 10/24/2023
7.0.12 4,185,701 10/10/2023
7.0.11 12,583,714 9/12/2023
7.0.10 9,205,004 8/8/2023
7.0.9 8,483,975 7/11/2023
7.0.8 5,239,805 6/22/2023
7.0.7 3,637,564 6/13/2023
7.0.5 24,453,462 4/11/2023
7.0.4 9,118,763 3/14/2023
7.0.3 13,233,998 2/14/2023
7.0.2 17,899,011 1/10/2023
7.0.1 9,637,804 12/13/2022
7.0.0 27,446,944 11/7/2022
7.0.0-rc.2.22472.11 214,814 10/11/2022
7.0.0-rc.1.22426.7 212,474 9/14/2022
7.0.0-preview.7.22376.2 95,206 8/9/2022
7.0.0-preview.6.22329.4 74,929 7/12/2022
7.0.0-preview.5.22302.2 63,930 6/14/2022
7.0.0-preview.4.22229.2 80,870 5/10/2022
7.0.0-preview.3.22175.1 77,684 4/13/2022
7.0.0-preview.2.22153.1 85,538 3/14/2022
7.0.0-preview.1.22076.6 57,276 2/17/2022
6.0.36 479,643 11/12/2024
6.0.35 457,770 10/8/2024
6.0.33 1,252,471 8/13/2024
6.0.32 639,012 7/9/2024
6.0.31 912,186 5/28/2024
6.0.30 458,568 5/14/2024
6.0.29 2,297,573 4/9/2024
6.0.28 1,354,825 3/12/2024
6.0.27 1,675,194 2/13/2024
6.0.26 2,431,870 1/9/2024
6.0.25 3,335,191 11/14/2023
6.0.24 1,726,224 10/24/2023
6.0.23 1,173,628 10/10/2023
6.0.22 3,177,807 9/12/2023
6.0.21 3,369,368 8/8/2023
6.0.20 2,711,972 7/11/2023
6.0.19 2,265,739 6/22/2023
6.0.18 1,219,450 6/13/2023
6.0.16 7,158,372 4/11/2023
6.0.15 3,992,464 3/14/2023
6.0.14 5,045,612 2/14/2023
6.0.13 6,671,286 1/10/2023
6.0.12 10,352,103 12/13/2022
6.0.11 9,549,475 11/7/2022
6.0.10 16,912,062 10/11/2022
6.0.9 14,817,110 9/13/2022
6.0.8 17,746,631 8/9/2022
6.0.7 47,865,922 7/12/2022
6.0.6 14,269,301 6/14/2022
6.0.5 21,784,127 5/10/2022
6.0.4 17,444,730 4/11/2022
6.0.3 23,676,979 3/8/2022
6.0.2 19,246,664 2/8/2022
6.0.1 31,711,316 12/14/2021
6.0.0 64,391,970 11/8/2021
6.0.0-rc.2.21480.5 320,448 10/12/2021
6.0.0-rc.1.21452.10 251,138 9/14/2021
6.0.0-preview.7.21378.4 95,660 8/10/2021
6.0.0-preview.6.21352.1 43,409 7/14/2021
6.0.0-preview.5.21301.9 184,994 6/15/2021
6.0.0-preview.4.21253.1 72,007 5/24/2021
6.0.0-preview.3.21201.2 95,228 4/8/2021
6.0.0-preview.2.21154.2 72,920 3/11/2021
6.0.0-preview.1.21102.2 94,830 2/12/2021
5.0.17 7,346,415 5/10/2022 5.0.17 is deprecated because it is no longer maintained.
5.0.16 1,468,508 4/11/2022 5.0.16 is deprecated because it is no longer maintained.
5.0.15 2,295,533 3/8/2022 5.0.15 is deprecated because it is no longer maintained.
5.0.14 2,324,755 2/8/2022 5.0.14 is deprecated because it is no longer maintained.
5.0.13 4,367,188 12/14/2021 5.0.13 is deprecated because it is no longer maintained.
5.0.12 4,762,827 11/7/2021 5.0.12 is deprecated because it is no longer maintained.
5.0.11 8,288,244 10/12/2021 5.0.11 is deprecated because it is no longer maintained.
5.0.10 13,176,055 9/14/2021 5.0.10 is deprecated because it is no longer maintained.
5.0.9 10,164,605 8/10/2021 5.0.9 is deprecated because it is no longer maintained.
5.0.8 9,439,005 7/13/2021 5.0.8 is deprecated because it is no longer maintained.
5.0.7 14,204,488 6/8/2021 5.0.7 is deprecated because it is no longer maintained.
5.0.6 8,101,765 5/11/2021 5.0.6 is deprecated because it is no longer maintained.
5.0.5 11,276,879 4/6/2021 5.0.5 is deprecated because it is no longer maintained.
5.0.4 8,203,793 3/9/2021 5.0.4 is deprecated because it is no longer maintained.
5.0.3 8,012,056 2/9/2021 5.0.3 is deprecated because it is no longer maintained.
5.0.2 10,445,029 1/12/2021 5.0.2 is deprecated because it is no longer maintained.
5.0.1 15,695,329 12/8/2020 5.0.1 is deprecated because it is no longer maintained.
5.0.0 26,128,503 11/9/2020 5.0.0 is deprecated because it is no longer maintained.
5.0.0-rc.2.20475.6 377,969 10/13/2020
5.0.0-rc.1.20451.13 318,184 9/14/2020
5.0.0-preview.8.20407.4 201,674 8/25/2020
5.0.0-preview.7.20365.15 113,967 7/21/2020
5.0.0-preview.6.20312.4 63,642 6/25/2020
5.0.0-preview.5.20278.2 48,560 6/10/2020
5.0.0-preview.4.20220.10 73,415 5/18/2020
5.0.0-preview.3.20181.2 94,063 4/23/2020
5.0.0-preview.2.20159.4 61,285 4/2/2020
5.0.0-preview.2.20120.8 45,908 3/16/2020
3.1.32 4,987,397 12/13/2022
3.1.31 1,007,905 11/8/2022
3.1.30 704,975 10/11/2022
3.1.29 1,196,332 9/13/2022
3.1.28 816,000 8/9/2022
3.1.27 723,346 7/12/2022
3.1.26 630,928 6/14/2022
3.1.25 1,066,816 5/10/2022
3.1.24 646,583 4/11/2022
3.1.23 1,047,079 3/8/2022
3.1.22 3,333,988 12/14/2021
3.1.21 2,581,126 11/7/2021
3.1.20 1,523,025 10/11/2021
3.1.19 2,444,526 9/14/2021
3.1.18 5,202,481 8/10/2021
3.1.17 1,862,506 7/13/2021
3.1.16 2,357,265 6/8/2021
3.1.15 2,792,044 5/11/2021
3.1.14 3,086,361 4/6/2021
3.1.13 4,547,678 3/9/2021
3.1.12 2,986,013 2/9/2021
3.1.11 5,401,586 1/12/2021
3.1.10 8,306,966 11/9/2020
3.1.9 11,945,621 10/13/2020
3.1.8 17,634,424 9/8/2020
3.1.7 9,960,646 8/11/2020
3.1.6 10,715,438 7/14/2020
3.1.5 12,741,087 6/9/2020
3.1.4 17,816,371 5/12/2020
3.1.3 27,724,876 3/24/2020
3.1.2 11,843,306 2/19/2020
3.1.1 19,853,576 1/14/2020
3.1.0 33,870,281 12/3/2019
3.1.0-preview3.19554.8 164,211 11/13/2019
3.1.0-preview2.19525.5 32,569 11/1/2019
3.1.0-preview1.19506.2 752,360 10/15/2019
3.0.3 186,499 2/19/2020
3.0.2 79,776 1/14/2020
3.0.1 1,395,361 11/18/2019
3.0.0 18,844,233 9/23/2019
3.0.0-rc1.19456.14 46,521 9/16/2019
3.0.0-preview9.19423.6 1,372,175 9/4/2019
3.0.0-preview8.19405.11 412,401 8/13/2019
3.0.0-preview7.19362.6 90,189 7/23/2019
3.0.0-preview6.19304.10 167,323 6/12/2019
3.0.0-preview5.19227.1 671,098 5/6/2019
3.0.0-preview4.19216.3 22,812 4/18/2019
3.0.0-preview3.19153.1 201,971 3/6/2019
3.0.0-preview.19074.3 31,181 1/29/2019
3.0.0-preview.18572.1 48,282 12/3/2018
2.3.0 3,433 1/14/2025
2.2.6 31,449,580 7/9/2019 2.2.6 is deprecated because it is no longer maintained.
2.2.4 19,426,058 4/9/2019 2.2.4 is deprecated because it is no longer maintained.
2.2.3 5,312,595 3/11/2019 2.2.3 is deprecated because it is no longer maintained.
2.2.2 6,398,306 2/12/2019 2.2.2 is deprecated because it is no longer maintained.
2.2.1 6,853,874 1/8/2019 2.2.1 is deprecated because it is no longer maintained.
2.2.0 21,370,776 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 184,484 10/17/2018
2.2.0-preview2-35157 147,307 9/12/2018
2.2.0-preview1-35029 81,175 8/22/2018
2.1.14 3,911,619 11/18/2019
2.1.11 3,685,799 5/14/2019
2.1.8 3,718,128 2/12/2019
2.1.4 15,459,227 10/1/2018
2.1.3 4,874,817 9/11/2018
2.1.2 8,073,530 8/21/2018
2.1.1 16,004,465 6/18/2018
2.1.0 13,159,350 5/29/2018
2.1.0-rc1-final 223,326 5/6/2018
2.1.0-preview2-final 204,451 4/10/2018
2.1.0-preview1-final 316,029 2/26/2018
2.0.3 5,291,211 5/7/2018 2.0.3 is deprecated because it is no longer maintained.
2.0.2 6,619,140 3/13/2018 2.0.2 is deprecated because it is no longer maintained.
2.0.1 12,404,127 11/14/2017 2.0.1 is deprecated because it is no longer maintained.
2.0.0 26,920,363 8/11/2017 2.0.0 is deprecated because it is no longer maintained.
2.0.0-preview2-final 95,695 6/28/2017 2.0.0-preview2-final is deprecated because it is no longer maintained.
2.0.0-preview1-final 1,107,478 5/10/2017 2.0.0-preview1-final is deprecated because it is no longer maintained.
1.1.6 5,716,153 7/10/2018 1.1.6 is deprecated because it is no longer maintained.
1.1.5 1,241,873 12/12/2017 1.1.5 is deprecated because it is no longer maintained.
1.1.4 221,108 11/14/2017 1.1.4 is deprecated because it is no longer maintained.
1.1.3 307,201 9/20/2017 1.1.3 is deprecated because it is no longer maintained.
1.1.2 4,932,894 5/9/2017 1.1.2 is deprecated because it is no longer maintained.
1.1.1 3,123,766 3/6/2017 1.1.1 is deprecated because it is no longer maintained.
1.1.0 6,977,653 11/16/2016 1.1.0 is deprecated because it is no longer maintained.
1.1.0-preview1-final 46,358 10/24/2016 1.1.0-preview1-final is deprecated because it is no longer maintained.
1.0.6 54,170 11/14/2017 1.0.6 is deprecated because it is no longer maintained.
1.0.5 42,653 9/20/2017 1.0.5 is deprecated because it is no longer maintained.
1.0.4 57,406 5/9/2017 1.0.4 is deprecated because it is no longer maintained.
1.0.3 633,438 3/6/2017 1.0.3 is deprecated because it is no longer maintained.
1.0.2 78,108 12/12/2016 1.0.2 is deprecated because it is no longer maintained.
1.0.1 763,392 9/13/2016 1.0.1 is deprecated because it is no longer maintained.
1.0.0 1,639,892 6/27/2016 1.0.0 is deprecated because it is no longer maintained.
1.0.0-rc2-final 138,051 5/16/2016 1.0.0-rc2-final is deprecated because it is no longer maintained.