mrahhal / Migrator.EF6

.NET Core CLI tool to enable EF6 migrations in an Asp.Net Core app.
MIT License
82 stars 15 forks source link

Version for package `Migrator.EF6.Tools` could not be resolved #55

Closed marchy closed 6 years ago

marchy commented 6 years ago

Set our project up on a new machine, and we can't seem to get around this issue: When running 'dotnet ef', we keep getting the error: "Version for package Migrator.EF6.Tools could not be resolved".

We've replicated all environmental differences we can think of, namely:

What else could be causing this? Is there any way to get more details on the error?

Some other context:

Kind thanks,

Marcel

mrahhal commented 6 years ago

First, please make sure you have both a PackageReference and a DotNetCliToolReference in your csproj. This is mentioned in the README, which I suggest you read thoroughly if you haven't done already. Most problems can be avoided in that way. (2.0.2 is the recommended version)

I just realized that you said:

(ie: targets both the full .NET Framework and .NET Core)

This package depends on EntityFramework6, obviously. So you can't simply reference it when you're targeting a platform other than full .net. Maybe you can elaborate on why you're targeting .NET Core even though you're using EF6 migrations in the same package?

But you're also saying that this used to work in another machine? How are you referencing things? (Maybe you're only referencing EF6 in a conditional platform == full .net?)

marchy commented 6 years ago

Thanks Mohammad, yes read the README many times and we have both PackageReference and DotNetClitoolReference in there, with PackageReference having PrivateAssets="All" specified as well.

The reason for the multi-targeting is that we have a DTO project which references some shared enums and custom exception classes that are used between both the Models layer and DTOs. I will try refactoring these out as to remove the multi-targeting side of this, but as mentioned this is all something that historically worked and is working on our previous machine. Perhaps it's something we have in the NuGet cache that's making it work in the old environment and may be a regression in the Migrator.EF6 library.

Will post back once we try out that refactoring to see if that's the culprit.

mrahhal commented 6 years ago

Generally, running this tool in a project that targets platforms other than full .Net is not supported at all. It wouldn't even compile (that's unless you manually do some pre-processing with ifdefs). And this, of course, makes sense. So, if it has been working for you, I'm not sure how. Yes, please feel free to elaborate on this if you discover something.

marchy commented 6 years ago

Hi @mrahhal, we finished the full refactoring of the .NET Standard domain project back into supporting only the full .NET framework but we're still getting the exact same error above.

Is there a particular version of .NET 4.x framework and .NET Core the migrator should (or should not run on)? What is the one you've perhaps been testing on?

Also do you know how we could possibly get more detail about the error? ie: Some sort of debug/verbose flag. It seems even running dotnet ef is enough to invoke the error.

mrahhal commented 6 years ago

The tool should be able to run with any version above NET46.

Oh, try installing .net sdk 1.1. It was already hard enough to get the tool to work and dispatch correctly, so some incongruities leak sometimes. So install sdk 1.1 if you don't have it (install it even if you have sdk 2.0)

Unfortunately, the error you're experiencing comes from the .net core sdk itself. It's saying it can't resolve the tool at all. Again, maybe installing sdk 1.1 will fix this. Let me know what happens. And if this doesn't solve it, maybe you can try to send me a project that this fails with, and I'll look into it.

marchy commented 6 years ago

Hey, we just tried this again with the new 2.1 version and we're getting the exact same issue still.

Tried installing .NET Core 1.1 but it doesn't seem to change anything. What's the easiest way to run the tool locally and debug it? We don't mind forking it and trying some things out to see where it breaks if you can let us know how to go about doing that.

PS: Here is the results from 'dotnet --info'

.NET Core SDK (reflecting any global.json): Version: 2.1.300 Commit: adab45bf0c

Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support): Version: 2.1.0 Commit: caa7b7e2ba

.NET Core SDKs installed: 1.1.8 [C:\Program Files\dotnet\sdk] 2.0.0 [C:\Program Files\dotnet\sdk] 2.0.2 [C:\Program Files\dotnet\sdk] 2.1.104 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

mrahhal commented 6 years ago

Hey,

Sorry to hear that you're still facing problems. Problem is you can't really debug the tool. I use logging to resolve most issues. Another problem is that you can't do much in this case even if you can debug, since this "resolve problem" is tied to the dotnet runtime and sdk when I dispatch an execution to dotnet.

All I can ask you right now is to clone this repo, and try to run the sample. The sample definitely runs, so you can start by trying to get it to work at first. And let me know what happens.

marchy commented 6 years ago

Oh fantastic! Got down to the bottom of it by seeing the error that happened in running the sample console app.

It turned out to be caused by this SQL Server 2017 problem: https://github.com/aspnet/EntityFrameworkCore/issues/11329 which was subsequently fixed in Cumulative Update 7 (https://dba.stackexchange.com/questions/191393/localdb-v14-creates-wrong-path-for-mdf-files)

Thanks for your continued promptness on the issues Mohammad - and for keeping the .NET community going with this life-saving tool (since the EF team can't seem to understand the importance of it) =)

mrahhal commented 6 years ago

Thanks for the kind words, glad you got it working!

pagner commented 3 years ago

I know this is old, but some of us are still using this...

If you come across this issue: Version for package Migrator.EF6.Tools could not be resolved

In package manager console run "dotnet restore". Be sure to select the project hosting EntityFramework

this fixed the issue for me using Visual Studio 2019