npgsql / efcore.pg

Entity Framework Core provider for PostgreSQL
PostgreSQL License
1.52k stars 223 forks source link

Warning: Found conflicts between different versions of "Microsoft.EntityFrameworkCore.Relational" that could not be resolved on Microsoft.EntityFrameworkCore.Relational 8.0.4 and 8.0.7 #3232

Closed darcome closed 3 weeks ago

darcome commented 1 month ago

This is the full message I receive when I try to use efcore 8.0.7 with the latest version of npgsql efcore.

Severity Code Description Project File Line Suppression State Warning (active) MSB3277 Found conflicts between different versions of "Microsoft.EntityFrameworkCore.Relational" that could not be resolved. There was a conflict between "Microsoft.EntityFrameworkCore.Relational, Version=8.0.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" and "Microsoft.EntityFrameworkCore.Relational, Version=8.0.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60". "Microsoft.EntityFrameworkCore.Relational, Version=8.0.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was chosen because it was primary and "Microsoft.EntityFrameworkCore.Relational, Version=8.0.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was not. References which depend on "Microsoft.EntityFrameworkCore.Relational, Version=8.0.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" Project file item includes which caused reference References which depend on or have been unified to "Microsoft.EntityFrameworkCore.Relational, Version=8.0.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" [].

Is there something I can do to have this warning disappear?

Thanks in advance!

roji commented 1 month ago

You'll have to post your csproj to provide the full context (just posting a warning/error is almost never enough), but you're likely explicitly refencing both Microsoft.EntityFrameworkCore.Relational and Npgsql.EntityFrameworkCore.PostgreSQL - there's no need for you to reference the former yourself (since the latter already references it for you); so try removing that.

darcome commented 1 month ago

I am not referencing Relational directly, I also run this command to be sure:

Get-ChildItem -Recurse -Filter *.cs | Select-String -Pattern "Relational"

however I found this in the project.assets.json file in the obj folder:

"Npgsql.EntityFrameworkCore.PostgreSQL/8.0.4": {
        "type": "package",
        "dependencies": {
          "Microsoft.EntityFrameworkCore": "8.0.4",
          "Microsoft.EntityFrameworkCore.Abstractions": "8.0.4",
          "Microsoft.EntityFrameworkCore.Relational": "8.0.4",
          "Npgsql": "8.0.3"
        },
        "compile": {
          "lib/net8.0/Npgsql.EntityFrameworkCore.PostgreSQL.dll": {
            "related": ".xml"
          }
        },
        "runtime": {
          "lib/net8.0/Npgsql.EntityFrameworkCore.PostgreSQL.dll": {
            "related": ".xml"
          }
        }
      },

I also tried to create a new solution but I wasn't able to reproduce it :(

felixsevero commented 3 weeks ago

You can just add an explicit reference to Microsoft.EntityFrameworkCore. I had the same problem and could resolve it as descbribed in https://github.com/npgsql/efcore.pg/issues/2294#issuecomment-1072360909

roji commented 3 weeks ago

I'll go ahead and close this as a repro is needed in order to investigate...