The problem: I have several
EntityFrameworkCore - based projects in the same VS solution, for example
MyNpgsqlEfModel. (It's kind of a complex data-integration scenario.) On top of that I have a CLI project which references all the three and performs actual data ops. When the CLI project references only
MyDb2EfModel project -
IBM.EntityFrameworkCore works as expected. But as soon as I add references to the remaining two projects - it simply stops working and throws some misleading exception. The exception happens because overridden
DbContext.OnModelCreating methods aren't called anymore. When there's only one reference (
MyDb2EfModel) the methods get called as expected, and everything works. But with all three library projects referenced - they aren't called anymore.
Let's also note that the mentioned methods get called on
DbContext instances from
MyNpgsqlEfModel libraries. The only one that stops working is
MyDb2EfModel (which is based on
Thumbs down for IBM and their .NET team! It's ridiculous how these guys are making things be 100 times more complicated then with any other DB.
The question is obvious: Does anyone has any experience in a similar scenario, and hopefully any suggestion how to resolve the issue?
I've found the reason. It turned out that it's about
Microsoft.EntityFrameworkCore version. Currently available version of
22.214.171.124 (.NET Standard 1.6), and it uses
1.1.2. It cannot be used with
2.0.0 (.NET Standard 2.0) - it throws the exception I was getting.
In the other two libraries I've used
2.0.0, both depending on
2.0.0 (all in .NET Standard 2.0).
So when I referenced only
MyDb2EfModel in my CLI project everything was working because only
1.1.2 is referenced and used. But as soon as I add reference to another projects CLI ends up with dependencies on both
2.0.0 versions, and the newer (
2.0.0) is loaded and used. And
IBM.EntityFrameworkCore was failing because it cannot use it.
How to solve? Either wait for
IBM.EntityFrameworkCore for .NET Standard 2.0, or downgrade other references to ensure that
2.0.0 isn't used anywhere (which will cause other headaches).
So although it's not about a bug in
IBM.EntityFrameworkCore, IBM DB2 .NET team is still to blame for not having .NET Standard 2.0 at least preview published, although .NET Standard 2.0 is available for almost a year now, recently reaching its "release" version. And there are more things to blame IBM DB2 .NET team for (unrelated to this particular issue).