dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.73k stars 3.18k forks source link

Pre-convention model missing method AreRequired() #28044

Open gagnedavid25 opened 2 years ago

gagnedavid25 commented 2 years ago

Hello,

Is there a reason why there is no AreRequired() method for the pre-convention model?

Usage:

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
    configurationBuilder.Properties<BlogCode>()
        .AreRequired();
}

I know that EF Core checks the nullability of the property for this, but we do not have NRT enable yet.

Thanks

AndriySvyryd commented 2 years ago

The requiredness of a property isn't usually dictated solely by its type (apart from whether it's nullable or non-nullable), but we could consider adding this if this gets enough votes.

gagnedavid25 commented 2 years ago

Thank you for your answer!

I realized I can enable NRT per file, so I will use this route.