I have a repository library that I use with an MVC application. It works great without any issues.
Currently, I'm building a new Client application using .Net Core. I referenced my existing repository project which has target framework 4.6.1. I can build without any issues.
When I tried to access the data using an existing DB Context. I was getting an error that it couldn't find a DefaultConnection string.
public class MyAppContext : DbContext
{
public MyAppContext():base("name=DefaultConnection"){}
this the connection I have in my config.json
"ConnectionStrings": {
"DefaultConnection": "Data Source=[SERVER]; Initial Catalog=[CATALOG]; User ID=[USERID];
Password=[PASSWORD];MultipleActiveResultSets=true;" },
I added an app.config file to my .Net Core application, like the one below
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlClient" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=[SERVER]; Initial Catalog=[CATALOG]; User ID=[USERID];
Password=[PASSWORD];MultipleActiveResultSets=true; " providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
and now I'm getting an error below
Message "The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information." string
I tried to install .net EntityFramework to my .net core application and I got a warning that it won't be fully compatible and I was getting the same error just shorter version.
How can I make .Net Core Web Application to share .Net 4.6 library without rewriting them to use .Net Core?