0
votes

I have an aspnetcore solution that I split into three projects:

  • Project.Core dnxcore50 Main app - startup resides here and has Project.EF & Project.Model dependency
  • Project.EF dotnet5.4 class libary - dbcontext resides here and has Project.Model dependency. dotnet-ef tools reside here
  • Project.Models dotnet5.4 class library

Using the dotnet cli tooling (dotnet-ef) I was able to add migrations to the project successfully. However when I execute update database to apply the migrations, I get an exception that I cant seem to resolve.

C:\Users\chris\Documents\project\core\src\Project.EF
dotnet ef database update -s ..\Project.Core

Could not load file or assembly 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

If anyone has some direction on how I can get this final piece working, it would be greatly appreciated. Below is copy of my Project.EF project.json

{
  "dependencies": {
    "Microsoft.EntityFrameworkCore": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.Commands": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*",
    "Microsoft.AspNetCore.Hosting": "1.0.0-*",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-*",
    "OpenIddict.EF": "1.0.0-*",
    "Project.Models": "1.0.0-*"
  },

  "frameworks": {
    "dotnet5.4": {
      "imports": "portable-net451+win8",
      "dependencies": {
        "System.Data.SqlClient": "4.0.0-*"
      }
    }
  },

  "tools": {
    "dotnet-ef": "1.0.0-*"
  }
}
1
We have seen several bugs cause this or similar exceptions. One example is github.com/dotnet/corefx/issues/3760. That particular issue was about the native part of SqlClient depending on a version of the C++ runtime library which required the Visual C++ 2012 Redistributable to be installed. The bug is supposedly fixed in code but the updated native binaries might not be published yet. If installing the redistributable doesn't help, you might me hitting another issue. I suggest you search in that bug database and create a new issue if you don't find a solution.divega
Another example was github.com/dotnet/corefx/issues/4776, which was fixed in RC1 Update 1.divega

1 Answers

-2
votes

The purpose of this design document is to define what Entity Framework requires from a SqlClient implementation to be used in EF7 with support for ASP.NET vNext on CoreCLR.

There are two separate components required to make this happen, System.Data.Common and a SqlClient implementation of System.Data.Common. This document covers the requirements for both of these components.

https://github.com/aspnet/EntityFramework/wiki/Design-SqlClient-for-EF7