-
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
Error when migrations are inside the webapp project #37
Comments
Hello, Are you still on project.json or are using the new tooling in VS 2017? Please check the README.md file. I'll quote the most important parts: Looking for the project.json version?Checkout the preview2 tree version of this repository. Release notesThe
|
Hi, I am currently using VS2017. My steps:
and I Created a new Itemgroup and added Migrator.EF6.Tools
There is only one project in my solution and it is a Web core based on .NET Framework. whole package output: PM> dotnet ef migrations enable Nelze na´┐Ż´┐Żst soubor nebo sestaven´┐Ż Microsoft.DotNet.PlatformAbstractions, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 nebo jeden z jejich z´┐Żvisl´┐Żch prvk´┐Ż. Zji´┐Żt´┐Żn´┐Ż definice manifestu sestaven´┐Ż neodpov´┐Żd´┐Ż odkazu na sestaven´┐Ż. (V´┐Żjimka na z´┐Żklad´┐Ż hodnoty HRESULT: 0x80131040) The last error is in Czech language saying It cannot find an assembly blablabla. Output says: PS: well, I installed it to really big project, so i will try it with a new project. EDIT: I created a new clean project, Iinstalled EF6, Migrator and added clitool into project. |
It seems to be a problem with the new version that supports tooling 1.0. I'll make some time soon to look into this. |
I confirmed this problem. This is only happening when the project has a dependency on Mvc it appears, which is a major blocker (I tested on a console app when I released that's why I didn't notice). I still have no idea what's going on though. |
The problem is with the dependency on "PlatformAbstractions". Dispatching to the full .Net framework itself is not discussed or documented anywhere after 1.0. I might just be doing something wrong, but I doubt it. I understand that this is a major blocker. I opened an issue with a repro on the cli repo for now: dotnet/cli#6028 |
In our solutions, we have a dedicated project (class library) for Entity framework dependency and it has no reference to Mvc. So, I don't have this problem @mrahhal |
@hikalkan thanks for your input. Moreover, I checked, and looks like the restriction that wouldn't allow core cli tools to run in class libraries in preview2 of tooling was removed, so that's super nice. @joshgarwood and @sagoo33 might be interested to know about this. @wh1sp3r the only workaround I see right now is to put your migrations in a pure class library project that doesn't have a dependency on anything aspnetcore related. Actually, I have a big webapp running in production, and I think I'll try moving migrations from the webapp to the "models" project. I think the reasonable thing to do right now is to recommend putting models + migrations in a separate pure class library project going forward. |
@mrahhal I use separate projects for MVC and EF (console app, containing migrations and models). Therefore, I am not affected. |
@Abdruggi yeah looks like that's the only way to go for now. I actually just updated a project, simply moving the migrations folder and moving the "Migrator.EF6.Tools" dependency to that class library does it. It's nice that tools finally support class libraries with no workarounds. |
Can't fix really. @wh1sp3r please try using a different class library for your migrations. If you're still facing problems after that feel free to open another issue. |
So there's basically a dependency that has a reference to Microsoft.Extensions.PlatformAbstractions v1.0.1.0, but since there's no assembly binding version redirect to the latest version (for me v1.1.1) it crashes with a FileLoadException. As a workaround you can create a binding redirect configuration in the build directory. Create <?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<gcServer enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.DotNet.PlatformAbstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNetCore.Identity" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> Looking at the necessary redirects, the problem might lie somewhere in Microsoft.AspNetCore.Identity, but I haven't looked into the issue far enough to be sure. Will add more info if I know more. Update: See my later post for a perhaps easier workaround. |
@nphmuller thanks! If you want you can add your findings at dotnet/cli#6028 which I opened to track the issue. |
@mrahhal I've added some additional details to the issue. |
As an easier to maintain workaround I currently just add a build target to my csproj file that copies the .config file from my main assembly: <!-- Workaround for Migrator.EF6 assembly version binding problem. See: https://github.com/mrahhal/Migrator.EF6/issues/37/ -->
<Target Name="ToolingAssemblyBinding" AfterTargets="Build">
<Copy SourceFiles="$(OutputPath)$(AssemblyName).exe.config" DestinationFiles="$(OutputPath)dotnet-ef.exe.config" />
</Target> |
Hi, working around is working ! I just have a last problem. if my project is set to AnyCPU, migrations are working fine but Kestrel is not working ( BadImageFormatException). If i set my project to x86, kestrel is working, but migrations are not becuase BadImageFormatException: cannot load my project. |
@wh1sp3r please open other issues for other problems. That said, I don't think this is a problem with this project. |
Thanks @nphmuller! |
Hello,
I have a problem with enabling migrations for my project.
After I wrote "dotnet ef migrations enable" into package console, it builds my project without any error and it shows an error that it's missing "Microsoft.DotNet.PlatformAbstractions, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60". I installed this library, but there is no version 1.0.1, just 1.0.3+ ( latest 1.1.1 ). It's shows same error.
Also there is an error in console output: Build Failure. Error: 'path' cannot be an empty string ("") or start with the null character.
Parameter name: path
if I installed "Microsoft.DotNet.PlatformAbstractions" 1.0.3 (only version which shows different output), it says something about different assembly versions and then It ends with an error that it cannot find assembly ( my project ).
Thanks! :)
The text was updated successfully, but these errors were encountered: