ErikEJ.EntityFramework.SqlServer 1.0.0-rc5
EF6 SQL Server provider based on Microsoft.Data.SqlClient
This Entity Framework 6 provider is a replacement provider for the built-in SQL Server provider. This provider depends on the modern Microsoft.Data.SqlClient ADO.NET provider, see my blog post here for why that can be desirable.
The latest build of this package is available from NuGet
Configuration
There are variuos ways to configure Entity Framework to use this provider.
You can register teh provider in code using an attribute:
[DbConfigurationType(typeof(MicrosoftSqlDbConfiguration))]
public class SchoolContext : DbContext
{
public SchoolContext() : base()
{
}
public DbSet<Student> Students { get; set; }
}
If you have multiple classes inheriting from DbContext in your solution, make sure add the DbConfigurationType attribute to all of them.
Or you can use the SetConfiguration method before any data access calls:
DbConfiguration.SetConfiguration(new System.Data.Entity.SqlServer.MicrosoftSqlDbConfiguration());
Or you can add the following lines to your existing DbConfiguration class:
SetProviderFactory(MicrosoftSqlProviderServices.ProviderInvariantName, Microsoft.Data.SqlClient.SqlClientFactory.Instance);
SetProviderServices(MicrosoftSqlProviderServices.ProviderInvariantName, MicrosoftSqlProviderServices.Instance);
// Optional
SetExecutionStrategy(MicrosoftSqlProviderServices.ProviderInvariantName, () => new MicrosoftSqlAzureExecutionStrategy());
You can also use XML/App.Config based configuration:
<entityFramework>
<providers>
<provider invariantName="Microsoft.Data.SqlClient" type="System.Data.Entity.SqlServer.MicrosoftSqlProviderServices, ErikEJ.EntityFramework.SqlServer" />
</providers>
</entityFramework>
If you use an EDMX file, make sure to update the Provider name there:
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<edmx:Runtime>
<edmx:StorageModels>
<Schema Namespace="ChinookModel.Store" Provider="Microsoft.Data.SqlClient" >
Code changes
In order to use the provider in an existing solution, a few code changes are required.
using System.Data.SqlClient;
=> using Microsoft.Data.SqlClient;
SqlAzureExecutionStrategy
=> MicrosoftSqlAzureExecutionStrategy
Feedback
Please report any issues and questions in the dedicated issue here
No packages depend on ErikEJ.EntityFramework.SqlServer.
.NET Framework 4.6.1
- EntityFramework (>= 6.4.0)
- Microsoft.Data.SqlClient (>= 2.1.3)
.NET Standard 2.1
- EntityFramework (>= 6.4.0)
- Microsoft.Data.SqlClient (>= 2.1.3)
Version | Downloads | Last updated |
---|---|---|
6.6.11 | 1 | 2/27/2025 |
6.6.10 | 1 | 2/27/2025 |
6.6.9 | 1 | 2/27/2025 |
6.6.8 | 1 | 2/27/2025 |
6.6.7 | 1 | 2/27/2025 |
6.6.6 | 1 | 2/27/2025 |
6.6.6-preview2 | 1 | 2/27/2025 |
6.6.6-preview1 | 1 | 2/27/2025 |
6.6.5 | 2 | 2/14/2024 |
6.6.4 | 1 | 2/27/2025 |
6.6.3 | 1 | 2/27/2025 |
6.6.2 | 1 | 2/27/2025 |
6.6.0 | 1 | 2/27/2025 |
6.6.0-rc1 | 1 | 2/27/2025 |
6.5.0 | 1 | 2/27/2025 |
6.5.0-rc1 | 1 | 2/27/2025 |
6.4.3 | 1 | 2/27/2025 |
6.4.2 | 1 | 2/27/2025 |
6.4.1 | 1 | 2/27/2025 |
6.4.1-preview1 | 1 | 2/27/2025 |
6.4.0 | 1 | 2/27/2025 |
1.0.0-rc5 | 1 | 2/27/2025 |