efcore is a free, open source databases project written in C# and released under MIT. It has 14,790 GitHub stars, 3,418 forks and 2,343 open issues, and was last pushed 4 hours ago. On this registry it ranks #52 of 143 tracked projects in Databases, with 5 head-to-head comparisons available.

What is efcore?

EF Core is a modern object-database mapper for .NET, maintained by Microsoft under the MIT License as a .NET Foundation project, and it is intended for .NET developers who want to work with relational and non-relational databases through LINQ queries, change tracking, updates, and schema migrations instead of hand-written data access code.

What it is

Entity Framework Core is an object-database mapper for .NET. It maps .NET classes to database tables and lets application code issue LINQ queries, track changes to loaded entities, persist updates, and evolve a schema through migrations. The repository at dotnet/efcore is also home to Microsoft.Data.Sqlite, and both projects are maintained by Microsoft and licensed under the MIT License.

The concrete thing it replaces is hand-written data access code: SQL strings, manual result-set materialisation, and hand-maintained mapping layers between objects and tables. EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MariaDB, MySQL, PostgreSQL, and other databases through a provider plugin API, so the same modelling and query surface applies across backends. The repository sits in the .NET ecosystem under the topics aspnet-product, c-sharp, dotnet-core, dotnet-framework, dotnet-standard, entity-framework, and orm.

Key capabilities

  • LINQ queries over mapped entities, as shown by the README example db.Blogs.OrderBy(b => b.BlogId).First().
  • Change tracking and persistence through SaveChanges(), which handles inserts, updates, and deletes against the tracked context.
  • Schema migrations, allowing the database schema to be generated and evolved from the model.
  • Provider plugin API supporting SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MariaDB, MySQL, and PostgreSQL, plus additional providers listed in the docs.
  • Provider-specific NuGet packages, including Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Sqlite, and Microsoft.EntityFrameworkCore.Cosmos.
  • Daily builds documented in docs/DailyBuilds.md, which carry the latest features and bug fixes ahead of previews and official releases.
  • Source builds for teams that prefer to compile and package the code themselves, per docs/getting-and-building-the-code.md.

Who uses it and how

  • .NET application teams across dotnet-core, dotnet-framework, and dotnet-standard who need one data access layer that follows the runtime they target.
  • ASP.NET product developers, indicated by the aspnet-product topic, using EF Core as the persistence layer behind web applications.
  • Teams targeting multiple database backends, using the provider plugin API to move between SQL Server, SQLite, PostgreSQL, MySQL, or Azure Cosmos DB.
  • Applications that embed a local database through Microsoft.Data.Sqlite, which ships from the same repository.
  • Contributors submitting pull requests for bug fixes, enhancements, and documentation, including through hacktoberfest; support questions are directed to Stack Overflow under the entity-framework-core tag.

Getting started

EF Core is installed from NuGet with the provider package for the target database, for example dotnet add package Microsoft.EntityFrameworkCore.SqlServer, dotnet add package Microsoft.EntityFrameworkCore.Sqlite, or dotnet add package Microsoft.EntityFrameworkCore.Cosmos, with a --version option available to install a preview version.

How it compares

The provided facts name no other object-database mapper or paid product that EF Core replaces, so no like-for-like comparison can be drawn from them. On the evidence available, it stands alone in this registry.

When to use it — and when not to

EF Core is a library rather than a service, so a self-hoster operates the target database itself, whether that is SQL Server, SQLite, PostgreSQL, MySQL, MariaDB, or Azure Cosmos DB, and is responsible for its availability, backups, and connection configuration. Teams that want no ORM layer between application code and SQL, or that depend on a database with no provider, should not pick it. The repository carries a substantial open issue count at 2,343, and its README directs most day-to-day guidance to external documentation, so teams should expect to rely on the docs and daily builds rather than the repository README alone.

project readme (upstream, from github) — read inline

Repository

build status test results

This repository is home to the following .NET Foundation projects. These projects are maintained by Microsoft and licensed under the MIT License.

Entity Framework Core

latest version preview version downloads

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MariaDB, MySQL, PostgreSQL, and other databases through a provider plugin API.

Installation

EF Core is available on NuGet. Install the provider package corresponding to your target database. See the list of providers in the docs for additional databases.

dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Cosmos

Use the --version option to specify a preview version to install.

Daily builds

We recommend using the daily builds to get the latest code and provide feedback on EF Core. These builds contain latest features and bug fixes; previews and official releases lag significantly behind.

Basic usage

The following code demonstrates basic usage of EF Core. For a full tutorial configuring the DbContext, defining the model, and creating the database, see getting started in the docs.

using var db = new BloggingContext();

// Inserting data into the database
db.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
db.SaveChanges();

// Querying
var blog = db.Blogs
    .OrderBy(b => b.BlogId)
    .First();

// Updating
blog.Url = "https://devblogs.microsoft.com/dotnet";
blog.Posts.Add(
    new Post
    {
        Title = "Hello World",
        Content = "I wrote an app using EF Core!"
    });
db.SaveChanges();

// Deleting
db.Remove(blog);
db.SaveChanges();

Build from source

Most people use EF Core by installing pre-built NuGet packages, as shown above. Alternatively, the code can be built and packages can be created directly on your development machine.

Contributing

We welcome community pull requests for bug fixes, enhancements, and documentation. See How to contribute for more information.

Getting support

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 issue. For more details, see getting support.

Microsoft.Data.Sqlite

latest version preview version downloads

Microsoft.Data.Sqlite is a lightweight ADO.NET provider for SQLite. The EF Core provider for SQLite is built on top of this library. However, it can also be used independently or with other data access libraries.

Installation

The latest stable version is available on NuGet.

dotnet add package Microsoft.Data.Sqlite

Use the --version option to specify a preview version to install.

Daily builds

We recommend using the daily builds to get the latest code and provide feedback on Microsoft.Data.Sqlite. These builds contain the latest features and bug fixes; previews and official releases lag significantly behind.

Basic usage

This library implements the common ADO.NET abstractions for connections, commands, data readers, and so on. For more information, see Microsoft.Data.Sqlite on Microsoft Docs.

using var connection = new SqliteConnection("Data Source=Blogs.db");
connection.Open();

using var command = connection.CreateCommand();
command.CommandText = "SELECT Url FROM Blogs";

using var reader = command.ExecuteReader();
while (reader.Read())
{
    var url = reader.GetString(0);
}

Build from source

Most people use Microsoft.Data.Sqlite by installing pre-built NuGet packages, as shown above. Alternatively, the code can be built and packages can be created directly on your development machine.

Contributing

We welcome community pull requests for bug fixes, enhancements, and documentation. See How to contribute for more information.

Getting support

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 issue. For more details, see getting support.

See also

Frequently asked questions

Is efcore free to use?

efcore is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does efcore do?

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.

What is efcore written in?

efcore is primarily written in C#. Its source is publicly available at https://github.com/dotnet/efcore, and it has 14,790 GitHub stars.