-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
Because UWP commands use netcore50 assemblies but actually execute on net451, we can run into issues with assembly versions.
Example error:
PS > Add-Migration Test
System.IO.FileLoadException: Could not load file or assembly 'System.IO.FileSystem.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.IO.FileSystem.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.Save(String projectDir, ScaffoldedMigration migration, String outputDir)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Other examples:
- design-time migrations don't fail with a load error, but still fail due to getting the wrong versions of BCL libraries such as DataAnnotations. See DataAnnotations not working in UWP at design-time #5945.
- design-time tools are bound to 1.0.0 assembly versions but need to execute against other versions such as 1.0.1. On UWP, NuGet won't add the necessary binding redirects. See Add-Migration doesn't work in a UWP project with EF Core 1.0.1 #6551.
Solution
We need to generate binding redirects so UWP tooling can get the right assembly versions
Workaround
Users can manually generate these. Add a file named "app.config" to the UWP project to explicitly redirect to the right assembly versions.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.Primitives"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0"
newVersion="4.0.1.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Overlapped"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0"
newVersion="4.0.1.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="4.1.0.0"
newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>noobhacker, nkkn1008 and lugerovacnoobhacker
Metadata
Metadata
Assignees
Labels
No labels