-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with projects targeting net47 #45
Comments
Haven't tested it on |
I think the problem is the GetTargetFramework method(ProjectReader.cs). The method should be more flexible. i will submit a pr. |
I would recommend something like this: public static NuGetFramework GetTargetFramework(string frameworkString)
{
if (frameworkString.StartsWith("netcoreapp", StringComparison.OrdinalIgnoreCase))
{
var versionText = frameworkString.Substring("netcoreapp".Length);
return new NuGetFramework(".NETCoreApp", FrameworkNameHelpers.GetVersion(versionText));
}
else if (frameworkString.StartsWith("netstandard", StringComparison.OrdinalIgnoreCase))
{
var versionText = frameworkString.Substring("netstandard".Length);
return new NuGetFramework(".NETStandard", FrameworkNameHelpers.GetVersion(versionText));
}
else if (frameworkString.StartsWith("net", StringComparison.OrdinalIgnoreCase))
{
var versionText = frameworkString.Substring("net".Length);
return new NuGetFramework(".NETFramework", FrameworkNameHelpers.GetVersion(versionText));
}
return new NuGetFramework(frameworkString);
} |
@Abdruggi Agreed. Would you like to submit a PR? |
@mrahhal I will submit the PR during the weekend, |
@mrahhal Pull request is ready for review (#46). Whereas the new code is perfectly running for the sample app (target framework net47) there are still some issues with the current project i am working on. but i don't no whether they are related to my project or the migrator. Need some more time for testing. |
@mrahhal It took me longer than expected, but i was able to track down my problem. Out of the box it is not possible to generate migrations for net4X projects referencing netstandard projects. The migrator or better the reflection part is looking for System.Runtime and some other libraries in version 4.1.0.0 but netstandard1.6 references them in version 4.1.1.0. It's a well known problem. The fix is pretty simple. Just create a file with the content below and the name "dotnet-ef.exe.config" in the net4X project and set copy to output to true. <?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Expressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> |
Well, this is a recurring problem it seems. And binding redirects are always involved. But since you've investigated, can you expand on this:
I didn't understand, I've always used this with net4x projects that referenced netstandard projects. Oh, but I guess the aspnet packages multi target both netstandard and net4x. So are you saying the problem occurs when the migrations project has a reference to a pure netstandard package? @nphmuller also mentioned a similar fix at #37. |
Exactly, my EF project (net47) references some infrastructure projects (pure netstandard1.6). Because of that, the mentioned libraries are to "new". 4.3 (4.1.1.0) instead of 4.1 (4.1.0.0). I would probably be a good idea to mention that in the readme. The necessary Migration project file (.csproj) changes: <ItemGroup>
<None Remove="dotnet-ef.exe.config" />
</ItemGroup>
<ItemGroup>
<Content Include="dotnet-ef.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup> |
Right now I'm recommending that people use migrations on a pure "Models" project, and reference that from their web app. But I should also mention this in the readme for people who really want to use other options. Thank you! |
The Migration Tools are not working with net47 projects. I am ending up getting following exception:
Unhandled Exception: Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-ef"
at Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.FindProjectDependencyCommands(String commandName, IEnumerable
1 commandArgs, String configuration, NuGetFramework framework, String outputPath, String buildBasePath, String projectDirectory) at Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.Create(String commandName, IEnumerable
1 args, NuGetFramework framework, String configuration)at Migrator.EF6.Tools.Program.Dispatch(String[] args)
at Migrator.EF6.Tools.Program.Main(String[] args)
Anyone having the same issue and a working fix?
The text was updated successfully, but these errors were encountered: