NickStrupat / EntityFramework.Triggers

Adds events for entity inserting, inserted, updating, updated, deleting, and deleted
MIT License
373 stars 46 forks source link

Problems in loading the right CoContra assembly in mixed application (.netstandard2.0 and .net462 projects) #18

Closed CTBT closed 7 years ago

CTBT commented 7 years ago

While upgrading our application to .netstandard 2.0 library projects and using those projects as nuget packages in a .net framework 4.6.2 web application project we get the following exeption on runtime.

exception_cocontra

the Nuget package of EntityFrameworkCore.Triggers was reference in the .netstandard2.0 library

I think there are two issues here:

  1. The application tries to load Version 1.0.1 of CoContra. I referenced the newest package of EntityFramework.Triggers 1.1.0 which actually references Cocontra 1.0.2.

  2. The .net461 web application tries to load the CoContra.net45.dll assembyl but actually needs the .netstandard1.0.dll. Before upgrading it worked to explicitly load the .netstandard1.0 assembly in csproj file.

At the moment we can´t use the official EntityFrameworCore.Triggers package anymore

NickStrupat commented 7 years ago

You're absolutely right. I am missing that scenario with my tests. Currently, only test .NET Core 2.0 and .NET Framework 4.6.1 actually run the tests for EFCore and EF, respectively.

I need a third scenario which tests EFCore on .NET Framework 4.6.1/2. More obviously, I need to update CoContra to make sure it plays nicely with those three test scenarios.

Thank you for posting this issue!

NickStrupat commented 7 years ago

I have upgrade CoContra to .NET Standard 2.0 and .NET Framework 4.6.1 and pushed a new package https://www.nuget.org/packages/CoContra/1.1.0

Commit is here: https://github.com/NickStrupat/CoContra/commit/7f9b71ff3aefc0e9d509b06861fae28b3bb11fb0

NickStrupat commented 7 years ago

So I have been working on getting .NET Framework 4.6.1 tests running against EntityFramework Core 2.0. The only way I can get it working is if I create a .NET Core application then switch its target framework to net461. Otherwise I end up with assembly loading exceptions at run-time, like this...

System.IO.FileLoadException: 'Could not load file or assembly "System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" or one of its dependencies. The definition of the assembly manifest found does not match the reference to the assembly.

Anyway, I hope this helps. Please let me know if you can't solve this.

NickStrupat commented 7 years ago

I've published an updated package at https://www.nuget.org/packages/EntityFrameworkCore.Triggers/1.1.1

CTBT commented 7 years ago

fix works. thanks! package refence now loads the right assembly