I'm deploying ASP.NET 5 application to Azure using VS2015. After successful deploy and opening my site in the browser I'm getting the error:
FileNotFoundException: 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.
The assembly is not directly referenced in my project. It is indirect dependency via EntityFramework.MicrosoftSqlServer assembly.
I had similar issue using ASP.NET 4 explained here: Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient' The solution named "the terrible hack" worked for me then. :)
Do you have any ideas what might be causing the problem and how to fix it?
Here is the content of my web app project.json:
{
"userSecretsId": "aspnet5-MyProject.Web-<A guid goes here>",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.Framework.CommandLineUtils.Sources": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"MyProject.Data": "1.0.0-*",
"System.Data.SqlClient": "4.0.0-beta-23516" <-- I've tried with this explicit dependency here
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
and the project.json of the MyProject.Data project that MyProject.Web is depending on:
{
"version": "1.0.0-*",
"description": "MyProject.Data Class Library",
"authors": [ "f012rt" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"commands": {
"ef": "EntityFramework.Commands"
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.Data.SqlClient": "4.0.0-beta-23516" <-- I've tried with this explicit dependency here
}
}
I've tried with explicitly specifying the missing dependency as you can see from my project.json files. I can confirm that the package "System.Data.SqlClient": "4.0.0-beta-23516" is in my [approot]\packages folder. The package folder looks exactly as this on my local computer. I've tried the deployment on a newly created Web App to avoid anything caused by old deplyments. The error is still the same.