efcore / EFCore.CheckConstraints

An Entity Framework Core plugin to automatically add check constraints in various situations
Apache License 2.0
291 stars 14 forks source link

Allow mapping via fluent API #165

Open cremor opened 4 weeks ago

cremor commented 4 weeks ago

It would be great if this library could also provide fluent mapping APIs to allow mapping of check constraints without using attributes.

Example: There is no HasMinLength() fluent mapping method. So you have to use a [StringLength(2, MinimumLength = 2)] attribute to get a min length check constraints.

roji commented 4 weeks ago

@cremor the point of this plugin is to provide support for standard .NET plugins which are already there - [StringLength] is part of .NET. If you just want to specify a minimum length check constraint in EF via the Fluent API, you can simply define the check constraint directly via EF's API (docs).

cremor commented 4 weeks ago

Yes, but with manually written check constraints I also have to manually do all the work that this library is already doing when I use attributes, like:

I like that this library does all that automatically 😄

roji commented 4 weeks ago

I'll leave this open in the backlog, but all the above really is trivial stuff - this plugin really was meant for making the built-in .NET attributes work, not making a really simple task even a big simpler :)