The specified deps.json '$$$' does not exist - entity-framework

I am rather new to the .NET Core, and I got a .NET Core WebAPI project MyWebApp,
also, i have .Net Core Class Library project MyLib using EntityFrameworkCore
When i try to use Add-Migration, i get the error
The specified deps.json [...\MyWebApp\bin\Debug\netcoreapp1.1\MyWebApp.deps.json] does not exist
Inspecting the folder, I noticed I have this a file in [...\MyWebApp\bin\Debug\netcoreapp1.1\win10-x64\MyWebApp.deps.json]
but i really can't figure what i am supposed to do to resolve this.
myWebApi project.json:
{
"dependencies": {
"ShopManager": "1.0.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": "1.1.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"runtimes": {
"win10-x64": ""
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}

runtimes section in project.json looks suspicious. As soon as you build for one runtime only - there is no need to use it.
Remove it and rewrite dependency from "Microsoft.NETCore.App":"1.1.0" to "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" }.
This will change your app deployment model from "self-contained" (can run on specific platform even without framework) to "framework-dependent" (may run on any platform with framework installed). Details are here.

I had this issue with Visual Studio 2017, I copied all the files including the dll's from the bin\Debug\netcoreapp1.0 to the bin\MCD\Debug\netcoreapp1.0
The scaffolding wasn't working correctly until I copied the files in the bin folder. I am not sure what the MCD folder does but for some reason the scaffolding process looks in this folder.

I ran into this issue during a conference workshop today. After running dotnet ef database update -v to get verbose output and carefully inspecting the paths there were used, I discovered that I had an environment variable set on my Mac that was causing the issue.
If you have PROJECTDIR set inside your environment, the dotnet command may use this to resolve paths and if it does, it will most likely do it in an unexpected manner. Therefore, remove this environment variable from the shell/environment where you are doing your .Net core work.

I had the same issue and realized it was due to having inconsistent build targets in projects. This is what fixed it for me:
Delete all bin and obj folders
Edit project files and solution file to ensure build targets match (e.g. only have debug|x64 and release|x64 everywhere)
Re-open visual studio and rebuild

Got this problem when I had multiple projects, even though I had selected my Api project as the default project in PMC, it still didn't work. I had to configure multiple startup projects and it was resolved.

Related

This version of the Entity Framework Core Package Manager Console Tools doesn't support these types of projects

After updating an existing project to ASP.NET Core 1.1 and Entity Framework Core 1.1 using this tutorial
I tried to execute "Add-Migration MigrationName" in Package Management Console but got an error:
Startup project 'src\ProjectName' is an ASP.NET Core or .NET Core
project for Visual Studio 2015. This version of the Entity Framework
Core Package Manager Console Tools doesn't support these types of
projects.
I am using VS 2015 Update 3.
Project.json
{
"dependencies": {
"CoursesManagement.DAL": "1.0.0-*",
"Microsoft.AspNetCore.Diagnostics": "1.1.1",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.1",
"Microsoft.AspNetCore.Mvc": "1.1.2",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.1",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.1",
"Microsoft.AspNetCore.StaticFiles": "1.1.1",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.1",
"Microsoft.Extensions.Configuration.Json": "1.1.1",
"Microsoft.Extensions.Logging.Console": "1.1.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.1",
"Microsoft.NETCore.App": "1.1.1",
"Microsoft.EntityFrameworkCore": "1.1.1",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Design": "1.1.1"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
},
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"runtimes": {
"win10-x64": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
global.json
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
As mentioned in this blog,
We’re now encouraging everyone to migrate to MSBuild and csproj from project.json. As I stated above, we will not be supporting any of the new .NET Core tools in Visual Studio 2015. We also won’t be updating the Visual Studio 2015 project.json-based tools.
You are using EFCore.Tools package version 1.1.0 which doesn't support project.json. The tooling for project.json never reached RTM. The suitable preview version to use for EF Core 1.1 packages is EFCore.Tools 1.1.0-preview4-final.
Also as mentioned in other answers, if you want to use powershell commands then you need to install EFCore.Tools package but if you want dotnet ef then you need to install EFCore.Tools.DotNet (version 1.1.0-preview3-final since preview4-final had minor issue).
As noted above, there will not be any updates to project.json-based tools. You can still use above preview package though best option would be to migrate to VS2017 csproj when you can.
As per official ASP.NET Core team announcement (see GitHub) the Microsoft.EntityFrameworkCore.Tools package was split into Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.Tools.DotNet.
You need to reference the later one, if you want to continue to use the dotnet ef commands. If you only want to use the old powershell styled commands (Database-Update, Add-Migration, etc.) the old package should be sufficient.
When referencing Microsoft.EntityFrameworkCore.Tools.DotNet``there is no need to also reference ``Microsoft.EntityFrameworkCore.Tools.
Quote by Rowan Miller
If you are using ASP.NET Core, then you need to update the tools
section of project.json to use the new
Microsoft.EntityFrameworkCore.Tools.DotNet package (rather than the
Microsoft.EntityFrameworkCore.Tools package).
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
},
As the design of .NET CLI Tools has
progressed, it has become necessary for us to separate the dotnet ef
tools into this separate package. Microsoft.EntityFrameworkCore.Tools
is still used for Package Manager Console commands.
Now that EF Core is released it should be of course
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0"
},
Also please note, that the tools do not share the version with the EF itself. The latest version of the tools is still 1.0.0 for Tools.DotNet(see Nuget) and 1.1.0 for Tools (see Nuget again).
I believe the commads are different in .NET Core and EF Core.
Try
dotnet ef migrations add MigrationName
and
dotnet ef database update
Here are the dotnet cli commands

Why don't my nuget versions match

I get this warning building my asp.net core project on teamcity, and also appears as a warning in visual studios:
Dependency specified was Foo.Client >= 1.0.0-* but ended up with Foo.Client 1.0.25523.
I don't understand why this doesn't match. I can't seem to find any documentation on how to make these wildcard strings.
1.0.25523 is a copy a replace operation I do on my build server to reflect the build number. It's not something I'd like to directly reference, I'm just confused as to why my 1.0.0-* isn't accepting something that looks just to differ by patch version.
My package config looks something like this:
{
"version": "1.0.0-*",
"dependencies": {
"Foo.Bar.Client": "1.0.0-*",
},
"frameworks": {
"net46": {
"dependencies": {
"Foo": {
"target": "project"
}
},
"frameworkAssemblies": {
}
}
}
}
And then the substitution is made here and in the Foo.Bar.Client project.json to change "version": "1.0.0-*" to "version": "1.0.25523"
There should be a *.nuspec file for your project, which will have the information about which package version you're using. From your error message, it seems that the package version in this file is 1.0.0 whereas you'll want to change this to 1.0.25523 I think.
You can also check here for some more information.

EF Core Tooling 1.1.0-preview4-final Not Compatible with Net46

I have an EF Core project which I recently upgraded to 1.1. Everything was working fine...until I tried to add a migration. Executing dotnet ef on the command line now generates an error about not being able to find the ef module/program.
Digging into this a bit I discovered that there was a breaking change in the EF Core 1 -> 1.1 transition involving the tooling. In project.json you have to replace this dependency:
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
with
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
Unfortunately...when I do that the package update fails with the error message that this version of the tooling does not support net46. Which I have to run under because of certain libraries that I'm using.
Here is the entire project.json file:
"version": "1.0.0-*",
"dependencies": {
"ConnellDataCore": "1.0.0-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
"Microsoft.Extensions.Configuration": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Serilog": "2.3.0"
},
"buildOptions": {
"emitEntryPoint": true,
"xmlDoc": false
},
"frameworks": {
"net46": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
}
}
},
"tools": {
}
I should also point out that the database is defined in a standalone-assembly, so I've had to use the "create a dummy static Program::Main()" trick, along with the "create a temporary context factory" trick.
How do I go about getting back to where I was, being able to add migrations to my EF Core database?
This is a known bug as of early February, 2017. The workaround is to revert to an earlier version of the tooling (in the project.json file):
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
Note, too, that the assembly path changed to Microsoft.EntityFrameworkCore.Tools.DotNet from Microsoft.EntityFrameworkCore.Tools.
Finally, in my particular case I'd mistakenly included the references in the dependencies section of the project.json file. They really belong in the tools section:
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
}

ASPNET Core/EF Core App on Top of Net46

I have an MVC6 website which has to run on top of the full net framework because it relies on various libraries which have not been updated to support Net Core.
I think I may be misconfiguring the project.json file. Here's what I have:
{
"dependencies": {
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Caching.Memory": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Serilog": "2.2.1",
"Serilog.Sinks.RollingFile": "3.0.1",
"Serilog.Sinks.Literate": "2.0.0",
"Serilog.Extensions.Logging": "1.2.0",
"AutoMapper": "5.1.1",
"WindowsAzure.Storage": "7.2.1",
"Microsoft.Azure.WebJobs": "1.1.2",
"Microsoft.WindowsAzure.ConfigurationManager": "3.2.1",
"UploadFramework": "1.0.0-*",
"ConnellDataCore": "1.0.0-*",
"ConnellData": "1.0.0-*",
"System.IO.Compression": "4.1.0",
"BundlerMinifier.Core": "2.2.281"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"net46": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
All of the projects that this one depends on are built on top of Net46. There project.json files all have entries like:
"frameworks": {
"net46": {
"frameworkAssemblies": {
"System.Configuration": "4.0.0.0"
}
}
}
although in this particular example I incorporated the frameworkAssemblies entry because I need access to ConfigurationManager (and if that's not the right way to solve that problem, please advise).
Is this the right way to configure an ASPNET Core/EF Core app to run on top of Net46? If not, what do I need to change?
Additional Info
The problems I'm running into involve the System.IO.Compression assembly. Specifically, what happened is that my solution built, but whenever the website tried to access a ZipArchive, it crashed. Because the System.IO.Compression.dll wasn't deployed to the site's bin directory (interestingly, System.IO.Compression.Zip.dll was deployed, but it's not useful with System.IO.Compression.dll).
I "solved" that problem by manually copying System.IO.Compression to the website's bin folder. But that manually copied DLL doesn't get deployed to Azure when the site is published, so the Azure-based site exhibits that same crashing problem.
In trying to solve this I dug around through all the various projects and checked the file versions of the System.IO.Compression DLLs. And I discovered an oddity: the System.IO.Compression DLL being included in my subsidiary projects (on which the website depends) are being deployed from the NetCore assembly cache, not the standard Net4.6 cache.
I don't know what this means. But I think it may be related to the problem I'm encountering.
So my goal is, somehow, to ensure that >>no<< project deploys any assembly from Net Core.
Unfortunately, I don't know how to do that. I suspect the issue involves some reference, perhaps ASPNET Core itself, which is insisting on/defaulting to using the Net Core assemblies. But I don't know how to tell it not to.
The dll not being copied isn't related to .net core, I'm not sure what the problem with that is, the dll isn't copied because there are no direct references to it in your code. The System.IO.Compression.Zip.dll is copied because somewhere in your code you are instantiating an object or calling a static method from that dll.
When entity framework 6 shipped they moved the SqlServer provider into a seperate dll and things broke all over the place because since no one had direct references to it in code it wasn't getting deployed.
Rob Lang has an interesting read on his adventures and eventual solution:
var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
I've also seen simular issues with all of the SqlServer Data Type dlls when deploying an application with local reports, there I took a different approach and referenced the dlls directly in the web project (there were so many) and set them all to copy local true, I believe that as long as the dlls are refrerenced in the project being published or deployed they will also be copied into the output folder, but if they're referenced by a class library that's referenced by the project being published/deployed they won't.

dnx build - type or namespace not found. Missing reference?

I have made an empty asp.net web app with the new dnu/dnx/vscode combo of utilities.
It's working fine until I try to add 3.party libraries.
I have tried to add MongoDB with the following cmd:
dnu install MongoDb.Driver
dnu restore
This adds the mongodb dependency to my project.json file:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Kestrel": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"MongoDb.Driver": "2.0.0"
},
...
but when I try to actually reference mongo, things fail:
using MongoDB.Bson;
VSCode gives me intellisense to add this namespace, but it adds a red squiggle under MongoDB and a green one under Bson.
when I try to build the project with
dnu build
it fails with the message
C:\source\.....cs(2,7): error CS0246: The type or namespace name 'MongoDB' could not be found (are you missing a using directive or an assembly reference?)
What am I missing here?
My project.json file is totally untouched - except for the added mongo dependency:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Kestrel": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"MongoDb.Driver": "2.0.0"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5001"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
Check what frameworks are listed in your project.json file and if you need an extra or different dependency for the coreclr-ish framework.
You may have to reload the editor as well when adding new dependencies. Command palette -> Reload Window
Answer on twitter regarding this issue
Edit: Probably not helping you, but this thread may be related. Seems like the MongoDB driver package is hard to get running with som versions of ASP.NET.
That is because MongoDb c# drive doesn't support CoreCLR yet. See this discussion. Simply remove the "dnxcore50": {} in your project.json and it will work.
Previously (Beta5) I got the same error doesn't give the meaning. Now I realize now in ASP.NET 5 Beta8 produce the meaningful error:
The dependency MongoDB.Driver.Core 2.1.0 in project does not support framework DNXCore,Version=v5.0.