Up to EF5, in order to connect to SQL Server 2012, all I needed to to is specify a connection string that looks something like this:
Data Source=.\SqlExpress;Initial Catalog=MyDatabase;Integrated security=True;MultipleActiveResultSets=True
This method is not working with EF6, giving exception
No Entity Framework provider found for 'System.Data.Odbc' ADO.NET provider. Make sure the provider is registered in the 'entityFramework' section of the application config file
I am not using app.config
file at all, I am passing above connection string to MyContext constructor. WHy is it trying to use Odbc provider at all, and instead not using System.Data.SqlClient?
What needs to be done to connect to SQL Server with EF6 code-first? I made sure that EntityFramework.dll and EntityFramework.SqlServer.dll are both available in Application folder. I have even added EF6 nuget package v6.0.0.1 in WPF project, although it does not use EF library directly, and making sure that automatically created App.Config file (by nuget) is copied to Application (Debug) folder - still no success.
I have also tried to setprovider manually in code:
public class OeeCoachConfiguration : DbConfiguration
{
public OeeCoachConfiguration()
{
SetProviderServices("System.Data.SqlClient",
System.Data.Entity.SqlServer.SqlProviderServices.Instance);
}
}
Still no success. My Project structure is as follows (simplified):
WPF project - does not have reference to EF (also tried adding EF reference)
ViewModel class library - does not have reference to EF
Model class library - has reference to EF library (both dlls)
Data class library - has reference to UI library (both dlls).
I am using CodeFirst approach, and this setup works without any problem with EF5. Any help is greatly appreciated.
Although Entity Framework 6. x is still supported, it is no longer being developed and will only receive fixes for security issues.
Keep using EF6 if the data access code is stable and not likely to evolve or need new features. Port to EF Core if the data access code is evolving or if the app needs new features only available in EF Core. Porting to EF Core is also often done for performance.
For me this error was resolved by removing the Glimpse.ADO package
Edit December 20, 2013 I believe the Glimpse.ADO package now supports EF6, but I have not tested it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With