1

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.

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Could you be more specific? How to configure HistoryContext for EFCore?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.