title: implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution
body: <p>Here is an excerpt from <a href="https://docs.asp.net/en/latest/data/entity-framework-6.html" rel="nofollow noreferrer">Getting Started with ASP.NET Core and Entity Framework 6</a>:</p>
  
  <blockquote>
    <p>"The recommended way to use Entity Framework 6 in an ASP.NET Core 1.0
    application is to put the EF6 context and model classes in a class
    library project (.csproj project file) that targets the full
    framework. Add a reference to the class library from the ASP.NET Core
    project. "</p>
  </blockquote>
  
  <p><strong>My Goal:</strong> is to implement both EntityFramework 6 and EntityFramework Core side-by-side in a n-tier solution.  </p>
  
  <p><strong>Solution:</strong></p>
  
  <ul>
  <li>ASP.NET Core Web Application (.NET Framework) with Individual User Accounts Authentication</li>
  <li>Windows Class Libraries (.dll) containing BLL &amp; DAL  </li>
  </ul>
  
  <p>The reason for implementing EF 6 and EF Core side-by-side is due to:</p>
  
  <ul>
  <li>EF Core 1.x implementation issues (migrations, many-to-zero relationships)</li>
  <li>Individual User Accounts Authentication in ASP.NET Core have a dependency on Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext</li>
  <li>This use-case will implement BreezeJS which currently depends on Entity Framework 6  </li>
  </ul>
  
  <p>I can successfully add migrations to the ASP.NET Core Web Application as follows:</p>
  
  <pre><code>PM&gt; EntityFrameworkCore\Add-Migration InitialCreate
  </code></pre>
  
  <p>However, I get an exception when attempting to add migrations to the Windows class library:</p>
  
  <pre><code>PM&gt; EntityFramework\Add-Migration InitialCreate
  </code></pre>
  
  <blockquote>
    <p>Exception calling "SetData" with "2" argument(s): "Type 
    'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject'
    in assembly  'Microsoft.VisualStudio.ProjectSystem.VS.Implementation,
    Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is
    not marked as serializable." At
    C:\Src\Hcs.NetCore\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720
    char:5
    +     $domain.SetData('startUpProject', $startUpProject)
    ...</p>
  </blockquote>
  
  <p>If I unload the ASP.NET Core Web Application, then I can successfully add EF6 migrations to the Windows class library with the following steps:</p>
  
  <pre><code>PM&gt; EntityFramework\enable-migrations
  PM&gt; EntityFramework\add-migration InitialCreate
  </code></pre>
  
  <p>Now I have the initial migration in both projects. </p>
  
  <p>However, when I run the ASP.NET Core Web Application I get a couple of runtime exceptions:</p>
  
  <p>If I have parameter-less constructor in my custom implementation of System.Data.Entity.DbContext, then I get the following runtime exception:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException was unhandled by user code …<br>
    Message=A network-related or instance-specific error occurred while
    establishing a connection to SQL Server. The server was not found or
    was not accessible. Verify that the instance name is correct and that
    SQL Server is configured to allow remote connections. (provider: SQL
    Network Interfaces, error: 26 - Error Locating Server/Instance
    Specified) …</p>
  </blockquote>
  
  <p>That was remedied by removing the default constructor.</p>
  
  <p>When I attempted to register a user, the following exception was thrown:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException (0x80131904): Cannot open database
    "xxx" requested by the login. The login failed. Login failed for user
    yyy\zzz'.    at
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
    identity, SqlConnectionString connectionOptions, SqlCredential
    credential, Object providerInfo, String newPassword, SecureString
    newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
    userConnectionOptions, SessionData reconnectSessionData,
    DbConnectionPool pool, String accessToken, Boolean
    applyTransientFaultHandling)    at</p>
  </blockquote>
  
  <p>Q - Am I on the right track? Is this now simply a SQL Server authentication issue? Or, are other issues involved?</p>