-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create EF-specific mapping attributes ('data annotations') #10864
Comments
Hi guys, that would be awesome if there was a data annotation for unique constraint. |
See also suggestion in #13627 |
@divega to consider as a duplicate. |
Duplicate of #10111 |
See also scenarios in #10111 |
Sorry to see this isn't included in the v5 planning. Stays a matter of personal preference but i like the clean approch of annotations. |
Removing from backlog to consider closing - we're tracking specific needs in specific issues. |
During 5.0 we have agreed on the approach decided here and are executing on it. Given that we have decided that this is the way to go we will track attributes individually and no longer need this overall tracking issue. |
Using C# attributes to drive EF mapping is very popular. Currently, we use data annotations (System.ComponentModel.DataAnnotations) for this, which has a couple of advantages:
However, there are also several disadvantages:
Because of this, we have already created a new attributes package: EFCore.Attributes. This contains new attributes like OwnedAttribute. This package will not have any references to the main EF Core assemblies so it can be included in a domain model with minimal impact--to avoid this entirely, use the fluent API.
This issue is about creating new, EF-specific, attributes even for concepts already covered by the data annotations. This would then allow higher fidelity mapping for EF Core using attributes instead of the fluent API, with all attributes in a single location that can be iterated on and released as EF Core evolves.
Note that this does not mean that we will stop honoring data annotations--that will keep working--but there will be another option with more EF-specific attributes that can be used optionally.
The text was updated successfully, but these errors were encountered: