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

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.

Showing the top 20 packages that depend on Microsoft.EntityFrameworkCore.

Packages Downloads
SanedBuildingBlocks
This package built for OIG-Saned
3,378
SanedBuildingBlocks
This package built for OIG-Saned
2,351
SanedBuildingBlocks
This package built for OIG-Saned
908
SanedBuildingBlocks
This package built for OIG-Saned
831
SanedBuildingBlocks
This package built for OIG-Saned
740
SanedBuildingBlocks
This package built for OIG-Saned
643
SanedBuildingBlocks
This package built for OIG-Saned
449
SanedBuildingBlocks
This package built for OIG-Saned
419
SanedBuildingBlocks
This package built for OIG-Saned
274
SanedBuildingBlocks
This package built for OIG-Saned
266
SanedBuildingBlocks
This package built for OIG-Saned
189
SanedBuildingBlocks
This package built for OIG-Saned
184
SanedBuildingBlocks
This package built for OIG-Saned
182
SanedBuildingBlocks
This package built for OIG-Saned
123
SanedBuildingBlocks
This package built for OIG-Saned
118
SanedBuildingBlocks
This package built for OIG-Saned
115
SanedBuildingBlocks
This package built for OIG-Saned
112
SanedBuildingBlocks
This package built for OIG-Saned
108
SanedBuildingBlocks
This package built for OIG-Saned
101
SanedBuildingBlocks
This package built for OIG-Saned
92

Version Downloads Last updated
9.0.0 15 12/01/2024
8.0.11 13 12/14/2024
8.0.0 12 02/22/2024
7.0.16 12 05/05/2024
7.0.14 13 12/31/2023
7.0.11 13 09/22/2023
7.0.10 13 08/16/2023
7.0.9 14 08/16/2023
7.0.8 13 06/22/2023
7.0.7 14 06/13/2023
7.0.1 12 10/07/2023
7.0.0 13 06/26/2023
6.0.13 14 09/21/2023
6.0.10 13 09/05/2023
6.0.7 14 06/19/2023
6.0.4 12 08/25/2023
6.0.1 12 06/19/2023
6.0.0 13 06/17/2023
5.0.10 11 06/16/2023
5.0.9 14 10/16/2023
3.1.3 12 08/16/2023