Open Liero opened 1 year ago
@Liero Both ČíselníkMateriál
and MaterialInfo2
are mapped to the same table, but in ČíselníkMateriál
, the Id
property is mapped to the column "ID", where as in MaterialInfo2
it retains its default mapping of "Id". EF column names are case-sensitive, so these are treated as different columns. Either map both to "ID" or both to "Id".
Yes, that solved it.
Also, both columns should be configured with .UseIdentityColumn(1, 1);
.
This could be a warning when building model, couldn't it?
Note from triage: warn in this case on SQL Server. (Warning will need to be disabled if this is intentional and master database is created with a collation that is not case-sensitive.)
File a bug
After I upgraded from .NET 6 and EF Core 6 to .NET 7 and EF Core 7.0.1 (SQL SERVER), I'm getting following exception when I try to add and save new entity:
The Id column is configured as IDENTITY, and it is not a PK.
Include your code
EntityEntry state before adding:
Entry metadata:
Include stack traces
Reproducible demo
https://github.com/Liero/EfCore.KeyIsNull
Include provider and version information