Microsoft.EntityFrameworkCore
9.0.0
Prefix Reserved
Requires NuGet 3.6 or higher.
dotnet add package Microsoft.EntityFrameworkCore --version 9.0.0
NuGet\Install-Package Microsoft.EntityFrameworkCore -Version 9.0.0
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
paket add Microsoft.EntityFrameworkCore --version 9.0.0
#r "nuget: Microsoft.EntityFrameworkCore, 9.0.0"
// Install Microsoft.EntityFrameworkCore as a Cake Addin #addin nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.0 // Install Microsoft.EntityFrameworkCore as a Cake Tool #tool nuget:?package=Microsoft.EntityFrameworkCore&version=9.0.0
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
- Getting Started with Entity Framework Core.
- Follow the ASP.NET Core Tutorial to use EF Core in a web app.
- Releases and planning(roadmap)
- How to write an EF Core provider
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 | Versions 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. |
-
net8.0
- Microsoft.EntityFrameworkCore.Abstractions (>= 9.0.0)
- Microsoft.EntityFrameworkCore.Analyzers (>= 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
NuGet packages (8.3K)
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 (597)
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 | 2,387,063 | 11/12/2024 | |
9.0.0-rc.2.24474.1 | 141,142 | 10/8/2024 | |
9.0.0-rc.1.24451.1 | 102,270 | 9/10/2024 | |
9.0.0-preview.7.24405.3 | 52,753 | 8/13/2024 | |
9.0.0-preview.6.24327.4 | 74,963 | 7/9/2024 | |
9.0.0-preview.5.24306.3 | 34,619 | 6/11/2024 | |
9.0.0-preview.4.24267.1 | 49,434 | 5/21/2024 | |
9.0.0-preview.3.24172.4 | 158,477 | 4/11/2024 | |
9.0.0-preview.2.24128.4 | 56,192 | 3/12/2024 | |
9.0.0-preview.1.24081.2 | 81,561 | 2/13/2024 | |
8.0.11 | 2,744,272 | 11/12/2024 | |
8.0.10 | 8,781,833 | 10/8/2024 | |
8.0.8 | 14,485,594 | 8/13/2024 | |
8.0.7 | 10,113,124 | 7/9/2024 | |
8.0.6 | 12,348,118 | 5/28/2024 | |
8.0.5 | 5,450,383 | 5/14/2024 | |
8.0.4 | 19,330,723 | 4/9/2024 | |
8.0.3 | 8,771,650 | 3/12/2024 | |
8.0.2 | 15,775,379 | 2/13/2024 | |
8.0.1 | 11,183,000 | 1/9/2024 | |
8.0.0 | 29,197,205 | 11/14/2023 | |
8.0.0-rc.2.23480.1 | 469,438 | 10/10/2023 | |
8.0.0-rc.1.23419.6 | 136,190 | 9/12/2023 | |
8.0.0-preview.7.23375.4 | 102,028 | 8/8/2023 | |
8.0.0-preview.6.23329.4 | 166,986 | 7/11/2023 | |
8.0.0-preview.5.23280.1 | 131,027 | 6/13/2023 | |
8.0.0-preview.4.23259.3 | 125,265 | 5/16/2023 | |
8.0.0-preview.3.23174.2 | 194,587 | 4/11/2023 | |
8.0.0-preview.2.23128.3 | 189,930 | 3/14/2023 | |
8.0.0-preview.1.23111.4 | 135,655 | 2/21/2023 | |
7.0.20 | 2,003,695 | 5/28/2024 | |
7.0.19 | 413,009 | 5/14/2024 | |
7.0.18 | 1,710,847 | 4/9/2024 | |
7.0.17 | 1,394,839 | 3/12/2024 | |
7.0.16 | 1,800,379 | 2/13/2024 | |
7.0.15 | 2,825,930 | 1/9/2024 | |
7.0.14 | 5,397,416 | 11/14/2023 | |
7.0.13 | 5,840,781 | 10/24/2023 | |
7.0.12 | 4,043,917 | 10/10/2023 | |
7.0.11 | 12,149,089 | 9/12/2023 | |
7.0.10 | 8,935,842 | 8/8/2023 | |
7.0.9 | 8,155,513 | 7/11/2023 | |
7.0.8 | 5,119,117 | 6/22/2023 | |
7.0.7 | 3,553,711 | 6/13/2023 | |
7.0.5 | 23,804,792 | 4/11/2023 | |
7.0.4 | 8,943,983 | 3/14/2023 | |
7.0.3 | 12,913,560 | 2/14/2023 | |
7.0.2 | 17,361,309 | 1/10/2023 | |
7.0.1 | 9,425,166 | 12/13/2022 | |
7.0.0 | 26,021,813 | 11/7/2022 | |
7.0.0-rc.2.22472.11 | 211,997 | 10/11/2022 | |
7.0.0-rc.1.22426.7 | 210,959 | 9/14/2022 | |
7.0.0-preview.7.22376.2 | 93,828 | 8/9/2022 | |
7.0.0-preview.6.22329.4 | 73,236 | 7/12/2022 | |
7.0.0-preview.5.22302.2 | 62,845 | 6/14/2022 | |
7.0.0-preview.4.22229.2 | 78,027 | 5/10/2022 | |
7.0.0-preview.3.22175.1 | 77,134 | 4/13/2022 | |
7.0.0-preview.2.22153.1 | 84,794 | 3/14/2022 | |
7.0.0-preview.1.22076.6 | 56,616 | 2/17/2022 | |
6.0.36 | 183,622 | 11/12/2024 | |
6.0.35 | 335,884 | 10/8/2024 | |
6.0.33 | 944,221 | 8/13/2024 | |
6.0.32 | 557,451 | 7/9/2024 | |
6.0.31 | 823,959 | 5/28/2024 | |
6.0.30 | 414,700 | 5/14/2024 | |
6.0.29 | 2,065,639 | 4/9/2024 | |
6.0.28 | 1,237,848 | 3/12/2024 | |
6.0.27 | 1,563,136 | 2/13/2024 | |
6.0.26 | 2,304,946 | 1/9/2024 | |
6.0.25 | 3,160,186 | 11/14/2023 | |
6.0.24 | 1,643,112 | 10/24/2023 | |
6.0.23 | 1,135,229 | 10/10/2023 | |
6.0.22 | 3,050,459 | 9/12/2023 | |
6.0.21 | 3,240,596 | 8/8/2023 | |
6.0.20 | 2,620,250 | 7/11/2023 | |
6.0.19 | 2,170,065 | 6/22/2023 | |
6.0.18 | 1,183,009 | 6/13/2023 | |
6.0.16 | 6,935,043 | 4/11/2023 | |
6.0.15 | 3,896,516 | 3/14/2023 | |
6.0.14 | 4,893,689 | 2/14/2023 | |
6.0.13 | 6,535,581 | 1/10/2023 | |
6.0.12 | 10,059,518 | 12/13/2022 | |
6.0.11 | 9,335,000 | 11/7/2022 | |
6.0.10 | 16,559,714 | 10/11/2022 | |
6.0.9 | 14,544,498 | 9/13/2022 | |
6.0.8 | 17,363,822 | 8/9/2022 | |
6.0.7 | 46,807,876 | 7/12/2022 | |
6.0.6 | 13,991,638 | 6/14/2022 | |
6.0.5 | 21,358,832 | 5/10/2022 | |
6.0.4 | 17,160,540 | 4/11/2022 | |
6.0.3 | 22,920,548 | 3/8/2022 | |
6.0.2 | 18,951,482 | 2/8/2022 | |
6.0.1 | 31,131,411 | 12/14/2021 | |
6.0.0 | 61,844,915 | 11/8/2021 | |
6.0.0-rc.2.21480.5 | 316,587 | 10/12/2021 | |
6.0.0-rc.1.21452.10 | 240,253 | 9/14/2021 | |
6.0.0-preview.7.21378.4 | 94,681 | 8/10/2021 | |
6.0.0-preview.6.21352.1 | 43,143 | 7/14/2021 | |
6.0.0-preview.5.21301.9 | 183,286 | 6/15/2021 | |
6.0.0-preview.4.21253.1 | 71,441 | 5/24/2021 | |
6.0.0-preview.3.21201.2 | 94,178 | 4/8/2021 | |
6.0.0-preview.2.21154.2 | 72,818 | 3/11/2021 | |
6.0.0-preview.1.21102.2 | 93,797 | 2/12/2021 | |
5.0.17 | 7,126,145 | 5/10/2022 | |
5.0.16 | 1,449,435 | 4/11/2022 | |
5.0.15 | 2,239,101 | 3/8/2022 | |
5.0.14 | 2,308,376 | 2/8/2022 | |
5.0.13 | 4,309,094 | 12/14/2021 | |
5.0.12 | 4,711,728 | 11/7/2021 | |
5.0.11 | 8,210,801 | 10/12/2021 | |
5.0.10 | 13,022,969 | 9/14/2021 | |
5.0.9 | 10,062,228 | 8/10/2021 | |
5.0.8 | 9,307,896 | 7/13/2021 | |
5.0.7 | 14,080,375 | 6/8/2021 | |
5.0.6 | 8,036,499 | 5/11/2021 | |
5.0.5 | 11,161,977 | 4/6/2021 | |
5.0.4 | 8,135,434 | 3/9/2021 | |
5.0.3 | 7,964,934 | 2/9/2021 | |
5.0.2 | 10,362,082 | 1/12/2021 | |
5.0.1 | 15,546,801 | 12/8/2020 | |
5.0.0 | 25,700,622 | 11/9/2020 | |
5.0.0-rc.2.20475.6 | 375,787 | 10/13/2020 | |
5.0.0-rc.1.20451.13 | 317,445 | 9/14/2020 | |
5.0.0-preview.8.20407.4 | 200,485 | 8/25/2020 | |
5.0.0-preview.7.20365.15 | 113,309 | 7/21/2020 | |
5.0.0-preview.6.20312.4 | 63,340 | 6/25/2020 | |
5.0.0-preview.5.20278.2 | 48,209 | 6/10/2020 | |
5.0.0-preview.4.20220.10 | 73,192 | 5/18/2020 | |
5.0.0-preview.3.20181.2 | 93,705 | 4/23/2020 | |
5.0.0-preview.2.20159.4 | 61,017 | 4/2/2020 | |
5.0.0-preview.2.20120.8 | 45,766 | 3/16/2020 | |
3.1.32 | 4,528,959 | 12/13/2022 | |
3.1.31 | 922,765 | 11/8/2022 | |
3.1.30 | 679,614 | 10/11/2022 | |
3.1.29 | 1,123,114 | 9/13/2022 | |
3.1.28 | 794,559 | 8/9/2022 | |
3.1.27 | 710,573 | 7/12/2022 | |
3.1.26 | 610,012 | 6/14/2022 | |
3.1.25 | 1,045,634 | 5/10/2022 | |
3.1.24 | 637,590 | 4/11/2022 | |
3.1.23 | 1,029,827 | 3/8/2022 | |
3.1.22 | 3,231,125 | 12/14/2021 | |
3.1.21 | 2,542,738 | 11/7/2021 | |
3.1.20 | 1,479,567 | 10/11/2021 | |
3.1.19 | 2,415,798 | 9/14/2021 | |
3.1.18 | 5,125,048 | 8/10/2021 | |
3.1.17 | 1,840,487 | 7/13/2021 | |
3.1.16 | 2,336,248 | 6/8/2021 | |
3.1.15 | 2,736,189 | 5/11/2021 | |
3.1.14 | 3,061,690 | 4/6/2021 | |
3.1.13 | 4,492,827 | 3/9/2021 | |
3.1.12 | 2,955,778 | 2/9/2021 | |
3.1.11 | 5,350,531 | 1/12/2021 | |
3.1.10 | 8,259,031 | 11/9/2020 | |
3.1.9 | 11,865,121 | 10/13/2020 | |
3.1.8 | 17,544,457 | 9/8/2020 | |
3.1.7 | 9,873,174 | 8/11/2020 | |
3.1.6 | 10,644,856 | 7/14/2020 | |
3.1.5 | 12,617,738 | 6/9/2020 | |
3.1.4 | 17,672,731 | 5/12/2020 | |
3.1.3 | 27,482,450 | 3/24/2020 | |
3.1.2 | 11,764,820 | 2/19/2020 | |
3.1.1 | 19,701,116 | 1/14/2020 | |
3.1.0 | 33,470,548 | 12/3/2019 | |
3.1.0-preview3.19554.8 | 163,990 | 11/13/2019 | |
3.1.0-preview2.19525.5 | 32,370 | 11/1/2019 | |
3.1.0-preview1.19506.2 | 744,845 | 10/15/2019 | |
3.0.3 | 184,396 | 2/19/2020 | |
3.0.2 | 79,399 | 1/14/2020 | |
3.0.1 | 1,387,678 | 11/18/2019 | |
3.0.0 | 18,673,477 | 9/23/2019 | |
3.0.0-rc1.19456.14 | 46,404 | 9/16/2019 | |
3.0.0-preview9.19423.6 | 1,364,048 | 9/4/2019 | |
3.0.0-preview8.19405.11 | 412,095 | 8/13/2019 | |
3.0.0-preview7.19362.6 | 89,962 | 7/23/2019 | |
3.0.0-preview6.19304.10 | 166,557 | 6/12/2019 | |
3.0.0-preview5.19227.1 | 670,447 | 5/6/2019 | |
3.0.0-preview4.19216.3 | 22,742 | 4/18/2019 | |
3.0.0-preview3.19153.1 | 201,509 | 3/6/2019 | |
3.0.0-preview.19074.3 | 30,871 | 1/29/2019 | |
3.0.0-preview.18572.1 | 48,013 | 12/3/2018 | |
2.2.6 | 31,194,316 | 7/9/2019 | |
2.2.4 | 19,324,547 | 4/9/2019 | |
2.2.3 | 5,293,051 | 3/11/2019 | |
2.2.2 | 6,368,046 | 2/12/2019 | |
2.2.1 | 6,822,848 | 1/8/2019 | |
2.2.0 | 21,103,699 | 12/3/2018 | |
2.2.0-preview3-35497 | 184,159 | 10/17/2018 | |
2.2.0-preview2-35157 | 145,587 | 9/12/2018 | |
2.2.0-preview1-35029 | 80,989 | 8/22/2018 | |
2.1.14 | 3,862,404 | 11/18/2019 | |
2.1.11 | 3,674,512 | 5/14/2019 | |
2.1.8 | 3,673,315 | 2/12/2019 | |
2.1.4 | 15,396,965 | 10/1/2018 | |
2.1.3 | 4,861,964 | 9/11/2018 | |
2.1.2 | 8,045,478 | 8/21/2018 | |
2.1.1 | 15,649,228 | 6/18/2018 | |
2.1.0 | 13,072,618 | 5/29/2018 | |
2.1.0-rc1-final | 222,720 | 5/6/2018 | |
2.1.0-preview2-final | 203,690 | 4/10/2018 | |
2.1.0-preview1-final | 315,391 | 2/26/2018 | |
2.0.3 | 5,254,480 | 5/7/2018 | |
2.0.2 | 6,568,026 | 3/13/2018 | |
2.0.1 | 12,314,617 | 11/14/2017 | |
2.0.0 | 26,624,090 | 8/11/2017 | |
2.0.0-preview2-final | 95,396 | 6/28/2017 | |
2.0.0-preview1-final | 1,098,729 | 5/10/2017 | |
1.1.6 | 5,626,984 | 7/10/2018 | |
1.1.5 | 1,236,520 | 12/12/2017 | |
1.1.4 | 219,391 | 11/14/2017 | |
1.1.3 | 306,293 | 9/20/2017 | |
1.1.2 | 4,877,341 | 5/9/2017 | |
1.1.1 | 3,086,777 | 3/6/2017 | |
1.1.0 | 6,742,459 | 11/16/2016 | |
1.1.0-preview1-final | 46,206 | 10/24/2016 | |
1.0.6 | 53,505 | 11/14/2017 | |
1.0.5 | 42,277 | 9/20/2017 | |
1.0.4 | 57,003 | 5/9/2017 | |
1.0.3 | 619,255 | 3/6/2017 | |
1.0.2 | 77,901 | 12/12/2016 | |
1.0.1 | 733,104 | 9/13/2016 | |
1.0.0 | 1,562,298 | 6/27/2016 | |
1.0.0-rc2-final | 136,182 | 5/16/2016 |