You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which set the CustomerId as nullable, if I use fluent api it's ok and will make it required.
Note that in the EF 5.0, it works as expected but EF 6.0 and 7.0 do not work.
Include provider and version information
EF Core version: 6.0.0 and 7.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
The text was updated successfully, but these errors were encountered:
Following is the minimal, runnable code sample I've used based on your code - please produce a similar sample (or tweak the below) to show the error happening.
Note for triage: still repros on latest daily build. Presumably, when CustomerId is changed from not being the key, its requiredness is also changed, even though it should not be since it was configured by data annotation.
@sa-es-ir Workaround (Edit: just noticed you already said that! :-)) is to configure the property as required in the fluent API:
I have an entity with these property:
If I add migration here is the generated one:
Which set the
CustomerId
as nullable, if I use fluent api it's ok and will make it required.Note that in the
EF 5.0
, it works as expected butEF 6.0 and 7.0
do not work.Include provider and version information
EF Core version: 6.0.0 and 7.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
The text was updated successfully, but these errors were encountered: