Closed ShahidRasheed closed 2 years ago
A small console app that demonstrates the issue - maybe you need Code based configuration as well (dispite the docs saying something else) - I have not done a lot of .NET Framwork testing.
@ErikEJ, what should be my defaultConnectionFactory? I have the following in my app config.
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
That looks wrong. I dont think my readme mentions that you should have that in your app.config.
But I cannot help you based on fragments of code, please share a runnable simple app that exhibits the issue.
This sample should demonstrate app.config based use with .NET Framework
https://github.com/ErikEJ/EntityFramework6PowerTools/tree/community/test%2FSmokeTestNetFx
Thanks, @ErikEJ. I had to register the provider in the code, and I see the app is now connecting. Please consider this issue closed.
Note: I also had to remove the defaultConnectionFactory
from the config.
@ShahidRasheed There was missing parts in the app.config configuration, you need to add this as well, then pure app.config based configuration will work:
<system.data>
<DbProviderFactories>
<add name="SqlClient Data Provider"
invariant="Microsoft.Data.SqlClient"
description=".NET Framework Data Provider for SqlServer"
type="Microsoft.Data.SqlClient.SqlClientFactory, Microsoft.Data.SqlClient" />
</DbProviderFactories>
</system.data>
@ErikEJ thanks, on comparison I see the type is different in my config. I will update the config and remove the code updates. Will send an update once done.
@ShahidRasheed all required config is documented in the readme.
Hi Erik, I am updating our NuGet libraries to use Microsoft.Data.SqlClient. Libraries use .Net framework 4.7.2, and I have installed Microsoft.Data.SqlClient, along with your package.
I am running into the following exception:
System.InvalidOperationException: The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type.
I have updated the config sections as per your suggestions:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
`
`
`
</system.data>`
My connection string has also been updated, and I am using Active Directory Managed Identity authentication; the following is a sample connection string.
<add name="ConStName" connectionString="Data Source={AzureManagedInstance};Initial Catalog={MyDB};Persist Security Info=True;Authentication=Active Directory Managed Identity;MultipleActiveResultSets=True" providerName="Microsoft.Data.SqlClient" />
Please let me know if you need any other details.