.NET Entity Framework Core Database Providers
.NET Entity Framework Core Database Providers

Database Providers For .NET Entity Framework Core Apps

In past articles, we have seen code examples which target Microsoft SQL Server database. Entity framework core can be used with multiple plugins (in form of NuGet packages). These plugins are called as database providers.

Available Database Providers

Entity framework core supports multiple database providers. Entity framework core supports many well-known databases (SQL or NoSQL) including Sql Server, MySQL, Sqlite, CosmosDB, PostgreSQL, etc.

In addition to those databases, entity framework core also supports In-Memory database. In-Memory database can be helpful for testing the applications which use entity framework based data layer.

Entity framework core project does not provide all the database provider implementations. Some database provider implementations are provided by third party organizations. When you plan to use any database provider, you should carefully review the database provider implementation from various perspectives, including but not limited to licensing, support, available features, existing issues, etc.

Full list of supported database providers can be seen in the documentation.

Some features of entity framework core are common to every database provider, while some other features are very much specific to database. For example the concept of foreign key is specific to relational databases only. The concept of memory-optimized tables is specific to SQL Server database and may not be applicable to other relational databases.

Using a Database Provider

Let’s have a look at how a database provider can be used. There are two important steps.

First step is to add reference to the NuGet package which provides the database provider implementation. The dotnet CLI command can be used to add a reference to appropriate NuGet package.

Second step is to instruct entity framework core to use the added database provider. This can be done at one of the two different places:

Below code example shows both the steps.

I hope you find this information helpful. Let me know your thoughts.

Leave a ReplyCancel reply