Closed moredatapls closed 3 years ago
You are likely specifying UseIdentityColumn in your model configuration - that extension method exists in both SqlServer and Npgsql, and the wrong version is getting resolved. Use that method with full qualification (e.g. NpgsqlPropertyBuilderExtensions.UseIdentityColumn(...)
if you intend to apply to Npgsql) to disambiguate.
For more help, can you please post your model config?
Wow that was it indeed, seems to work now. The curse of extension methods! Are you aware of other possible conflicts or are there any resources on this?
I've just now merged a patch to fix a very similar problem in migrations - see https://github.com/dotnet/efcore/issues/23456. Aside from UseIdentityColumn, IncludeProperties on indexes is also a culprit.
We're running two databases, one SQL Server and one PostgreSQL instance. We're already connecting to the SQL Server through EF Core. Now, we would like to add a second context that connects to the PostgreSQL server.
However, as soon as we add the Npgsql dependency to our project, strange exceptions happen when writing to the SQL Server through EF Core. The only change is the dependency, no other changes are made to our project. Example of one of the exceptions that happen:
Our .csproj before the change (simplified, there are many other dependencies too):
After the change:
Do you have an idea what could be the cause of the problems?