.NET Core - Targetting old .NET framework
<p>What I want to do: use an older project (.NET 3.5) data context and repositories in a .net core application (targetting .net 4.5). I put a more detailed explanation and what I tried below.</p>
<p><strong>What I want to do</strong></p>
<p>I am building a MVC application using .NET Core (on .NET 4.6 framework) at my work. The application needs to integrate with an existing database.</p>
<p>Normally in my .NET Core MVC applications, in <code>startup.cs</code> I do something like:</p>
<p><code>services.DbContext&lt;Context&gt;(options...)</code> and parse a connection string. I then do <code>services.AddTransient</code>... and inject a repository to my controllers, which lets me access the database.</p>
<p>However, instead of setting up my own database context and repositories and queries, I would like to use the existing codebase at my work. I created my project in the same solution as the existing ones. The existing projects are web forms, and use .NET 3.5. The way they do the database and repositories is a bit different - it uses <code>DataContext</code> in <code>System.Data.Linq</code>, and reads a connection string from <code>web.config</code>. Instead of dependency injection, then, the controllers just instantiate an instance of this class.</p>
<p><strong>What I have tried</strong></p>
<p>In my <code>startup.cs</code>, I tried to create a DataContext and parse it into the other project's repository, but it said something like <code>You need to reference </code>System.Data.Linq<code> in the .NET framework 3.5.0</code>.</p>
<p>Is it possible for a .NET Core project targeting .NET 4.5, to use data context classes and repositories built using .NET 3.5?</p>