Microsoft.EntityFrameworkCore 8.0.7

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

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

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7.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 (561)

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
9.0.0-preview.6.24327.4 11,651 7/9/2024
9.0.0-preview.5.24306.3 22,459 6/11/2024
9.0.0-preview.4.24267.1 25,794 5/21/2024
9.0.0-preview.3.24172.4 95,017 4/11/2024
9.0.0-preview.2.24128.4 41,728 3/12/2024
9.0.0-preview.1.24081.2 58,101 2/13/2024
8.0.7 1,120,399 7/9/2024
8.0.6 4,803,605 5/28/2024
8.0.5 2,500,154 5/14/2024
8.0.4 7,877,747 4/9/2024
8.0.3 5,353,105 3/12/2024
8.0.2 8,831,696 2/13/2024
8.0.1 7,353,545 1/9/2024
8.0.0 15,309,570 11/14/2023
8.0.0-rc.2.23480.1 391,743 10/10/2023
8.0.0-rc.1.23419.6 124,617 9/12/2023
8.0.0-preview.7.23375.4 78,637 8/8/2023
8.0.0-preview.6.23329.4 128,526 7/11/2023
8.0.0-preview.5.23280.1 114,283 6/13/2023
8.0.0-preview.4.23259.3 110,304 5/16/2023
8.0.0-preview.3.23174.2 159,292 4/11/2023
8.0.0-preview.2.23128.3 179,637 3/14/2023
8.0.0-preview.1.23111.4 129,130 2/21/2023
7.0.20 409,940 5/28/2024
7.0.19 224,272 5/14/2024
7.0.18 807,608 4/9/2024
7.0.17 983,689 3/12/2024
7.0.16 1,413,269 2/13/2024
7.0.15 2,188,536 1/9/2024
7.0.14 4,441,337 11/14/2023
7.0.13 4,785,259 10/24/2023
7.0.12 3,550,793 10/10/2023
7.0.11 10,137,416 9/12/2023
7.0.10 7,792,123 8/8/2023
7.0.9 6,893,853 7/11/2023
7.0.8 4,547,875 6/22/2023
7.0.7 3,183,980 6/13/2023
7.0.5 21,116,871 4/11/2023
7.0.4 8,222,745 3/14/2023
7.0.3 11,597,413 2/14/2023
7.0.2 15,333,114 1/10/2023
7.0.1 8,584,257 12/13/2022
7.0.0 21,342,105 11/7/2022
7.0.0-rc.2.22472.11 200,964 10/11/2022
7.0.0-rc.1.22426.7 204,612 9/14/2022
7.0.0-preview.7.22376.2 86,548 8/9/2022
7.0.0-preview.6.22329.4 67,719 7/12/2022
7.0.0-preview.5.22302.2 59,563 6/14/2022
7.0.0-preview.4.22229.2 73,098 5/10/2022
7.0.0-preview.3.22175.1 73,825 4/13/2022
7.0.0-preview.2.22153.1 83,056 3/14/2022
7.0.0-preview.1.22076.6 52,310 2/17/2022
6.0.32 87,371 7/9/2024
6.0.31 360,670 5/28/2024
6.0.30 201,516 5/14/2024
6.0.29 988,127 4/9/2024
6.0.28 745,542 3/12/2024
6.0.27 1,069,689 2/13/2024
6.0.26 1,749,852 1/9/2024
6.0.25 2,403,653 11/14/2023
6.0.24 1,310,725 10/24/2023
6.0.23 955,056 10/10/2023
6.0.22 2,495,355 9/12/2023
6.0.21 2,650,941 8/8/2023
6.0.20 2,218,306 7/11/2023
6.0.19 1,758,954 6/22/2023
6.0.18 1,026,929 6/13/2023
6.0.16 6,038,432 4/11/2023
6.0.15 3,459,853 3/14/2023
6.0.14 4,313,512 2/14/2023
6.0.13 5,868,295 1/10/2023
6.0.12 8,836,855 12/13/2022
6.0.11 8,499,027 11/7/2022
6.0.10 15,090,186 10/11/2022
6.0.9 13,421,680 9/13/2022
6.0.8 15,821,978 8/9/2022
6.0.7 42,195,924 7/12/2022
6.0.6 12,869,686 6/14/2022
6.0.5 19,650,033 5/10/2022
6.0.4 15,896,144 4/11/2022
6.0.3 20,830,439 3/8/2022
6.0.2 17,825,532 2/8/2022
6.0.1 28,868,242 12/14/2021
6.0.0 53,608,543 11/8/2021
6.0.0-rc.2.21480.5 306,319 10/12/2021
6.0.0-rc.1.21452.10 209,050 9/14/2021
6.0.0-preview.7.21378.4 89,610 8/10/2021
6.0.0-preview.6.21352.1 42,293 7/14/2021
6.0.0-preview.5.21301.9 177,452 6/15/2021
6.0.0-preview.4.21253.1 70,738 5/24/2021
6.0.0-preview.3.21201.2 91,593 4/8/2021
6.0.0-preview.2.21154.2 70,687 3/11/2021
6.0.0-preview.1.21102.2 91,777 2/12/2021
5.0.17 6,329,947 5/10/2022
5.0.16 1,371,220 4/11/2022
5.0.15 2,098,428 3/8/2022
5.0.14 2,230,015 2/8/2022
5.0.13 4,104,676 12/14/2021
5.0.12 4,514,775 11/7/2021
5.0.11 7,874,050 10/12/2021
5.0.10 12,454,492 9/14/2021
5.0.9 9,683,818 8/10/2021
5.0.8 8,834,045 7/13/2021
5.0.7 13,517,024 6/8/2021
5.0.6 7,776,849 5/11/2021
5.0.5 10,750,392 4/6/2021
5.0.4 7,860,173 3/9/2021
5.0.3 7,774,765 2/9/2021
5.0.2 10,102,996 1/12/2021
5.0.1 14,965,441 12/8/2020
5.0.0 24,192,600 11/9/2020
5.0.0-rc.2.20475.6 369,902 10/13/2020
5.0.0-rc.1.20451.13 315,116 9/14/2020
5.0.0-preview.8.20407.4 197,425 8/25/2020
5.0.0-preview.7.20365.15 111,754 7/21/2020
5.0.0-preview.6.20312.4 62,257 6/25/2020
5.0.0-preview.5.20278.2 47,141 6/10/2020
5.0.0-preview.4.20220.10 71,843 5/18/2020
5.0.0-preview.3.20181.2 91,938 4/23/2020
5.0.0-preview.2.20159.4 59,895 4/2/2020
5.0.0-preview.2.20120.8 45,229 3/16/2020
3.1.32 3,275,448 12/13/2022
3.1.31 686,736 11/8/2022
3.1.30 590,878 10/11/2022
3.1.29 909,065 9/13/2022
3.1.28 694,446 8/9/2022
3.1.27 650,651 7/12/2022
3.1.26 553,413 6/14/2022
3.1.25 969,751 5/10/2022
3.1.24 600,031 4/11/2022
3.1.23 967,101 3/8/2022
3.1.22 2,957,468 12/14/2021
3.1.21 2,370,986 11/7/2021
3.1.20 1,346,178 10/11/2021
3.1.19 2,312,059 9/14/2021
3.1.18 4,885,925 8/10/2021
3.1.17 1,758,971 7/13/2021
3.1.16 2,213,998 6/8/2021
3.1.15 2,565,819 5/11/2021
3.1.14 2,953,880 4/6/2021
3.1.13 4,291,455 3/9/2021
3.1.12 2,867,940 2/9/2021
3.1.11 5,163,662 1/12/2021
3.1.10 8,065,462 11/9/2020
3.1.9 11,547,871 10/13/2020
3.1.8 17,140,339 9/8/2020
3.1.7 9,486,550 8/11/2020
3.1.6 10,333,155 7/14/2020
3.1.5 12,234,925 6/9/2020
3.1.4 17,142,533 5/12/2020
3.1.3 26,552,846 3/24/2020
3.1.2 11,464,579 2/19/2020
3.1.1 19,096,569 1/14/2020
3.1.0 31,953,354 12/3/2019
3.1.0-preview3.19554.8 160,074 11/13/2019
3.1.0-preview2.19525.5 31,897 11/1/2019
3.1.0-preview1.19506.2 717,816 10/15/2019
3.0.3 176,533 2/19/2020
3.0.2 78,221 1/14/2020
3.0.1 1,352,871 11/18/2019
3.0.0 18,059,797 9/23/2019
3.0.0-rc1.19456.14 45,825 9/16/2019
3.0.0-preview9.19423.6 1,330,160 9/4/2019
3.0.0-preview8.19405.11 396,620 8/13/2019
3.0.0-preview7.19362.6 87,790 7/23/2019
3.0.0-preview6.19304.10 160,968 6/12/2019
3.0.0-preview5.19227.1 647,537 5/6/2019
3.0.0-preview4.19216.3 22,438 4/18/2019
3.0.0-preview3.19153.1 196,648 3/6/2019
3.0.0-preview.19074.3 30,370 1/29/2019
3.0.0-preview.18572.1 46,957 12/3/2018
2.2.6 30,302,279 7/9/2019
2.2.4 18,921,542 4/9/2019
2.2.3 5,216,467 3/11/2019
2.2.2 6,244,766 2/12/2019
2.2.1 6,700,889 1/8/2019
2.2.0 20,138,183 12/3/2018
2.2.0-preview3-35497 182,932 10/17/2018
2.2.0-preview2-35157 142,641 9/12/2018
2.2.0-preview1-35029 80,358 8/22/2018
2.1.14 3,706,030 11/18/2019
2.1.11 3,630,988 5/14/2019
2.1.8 3,535,319 2/12/2019
2.1.4 15,111,817 10/1/2018
2.1.3 4,806,520 9/11/2018
2.1.2 7,943,677 8/21/2018
2.1.1 14,547,391 6/18/2018
2.1.0 12,711,328 5/29/2018
2.1.0-rc1-final 216,160 5/6/2018
2.1.0-preview2-final 195,878 4/10/2018
2.1.0-preview1-final 309,643 2/26/2018
2.0.3 5,122,357 5/7/2018
2.0.2 6,420,369 3/13/2018
2.0.1 12,020,318 11/14/2017
2.0.0 25,335,162 8/11/2017
2.0.0-preview2-final 93,529 6/28/2017
2.0.0-preview1-final 1,072,326 5/10/2017
1.1.6 5,235,957 7/10/2018
1.1.5 1,211,211 12/12/2017
1.1.4 213,543 11/14/2017
1.1.3 301,650 9/20/2017
1.1.2 4,681,792 5/9/2017
1.1.1 2,919,681 3/6/2017
1.1.0 6,167,060 11/16/2016
1.1.0-preview1-final 45,604 10/24/2016
1.0.6 51,798 11/14/2017
1.0.5 41,219 9/20/2017
1.0.4 55,910 5/9/2017
1.0.3 582,372 3/6/2017
1.0.2 77,333 12/12/2016
1.0.1 663,047 9/13/2016
1.0.0 1,366,093 6/27/2016
1.0.0-rc2-final 131,125 5/16/2016