Reputation: 1627
Is there any way I can use DbConfiguration in .net core? For ex:
public class DbConfig : DbConfiguration
{
public DbConfig()
{
SetProviderServices("System.Data.SqlClient",
System.Data.Entity.SqlServer.SqlProviderServices.Instance);
}
}
I assume I need to get a .net framework dll and reference it in my project in order to use that class? My purpose of doing it is to put a annotation on DbContext class like below:
[DbConfigurationType(typeof(DbConfig))]
public class MyDbContext : DbContext
and ultimately implement this in .net core way.
Upvotes: 1
Views: 6229
Reputation: 1349
If you are developing your ASP.NET core using full .Net Framework (.Net 4.6) then all you need to do is add the dependency as below to your project.json file
"frameworks": {
"net46": {}
}
The DbConfiguration class from EntityFramework will be available to you.
But, If you are developing your ASP.NET Core using .NET Core, you need to use EntityFramework Core Configuring DbContext
Upvotes: 3