Database Providers

12/17/2019

3 minutes to read

+9



In this article

Entity Framework Core can access many different databases through plug-in libraries called database providers.

Current providers

Important EF Core providers are built by a variety of sources. Not all providers are maintained as part of the Entity Framework Core Project. When considering a provider, be sure to evaluate quality, licensing, support, etc. to ensure they meet your requirements. Also make sure you review each provider's documentation for detailed version compatibility information.

Important EF Core providers typically work across minor versions, but not across major versions. For example, a provider released for EF Core 2.1 should work with EF Core 2.2, but will not work with EF Core 3.0.

Adding a database provider to your application

Most database providers for EF Core are distributed as NuGet packages, and can be installed as follows:

Once installed, you will configure the provider in your DbContext , either in the OnConfiguring method or in the AddDbContext method if you are using a dependency injection container. For example, the following line configures the SQL Server provider with the passed connection string:

optionsBuilder.UseSqlServer( "Server=(localdb)\mssqllocaldb;Database=MyDatabase;Trusted_Connection=True;");

Database providers can extend EF Core to enable functionality unique to specific databases. Some concepts are common to most databases, and are included in the primary EF Core components. Such concepts include expressing queries in LINQ, transactions, and tracking changes to objects once they are loaded from the database. Some concepts are specific to a particular provider. For example, the SQL Server provider allows you to configure memory-optimized tables (a feature specific to SQL Server). Other concepts are specific to a class of providers. For example, EF Core providers for relational databases build on the common Microsoft.EntityFrameworkCore.Relational library, which provides APIs for configuring table and column mappings, foreign key constraints, etc. Providers are usually distributed as NuGet packages.