-
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
Provide a data annotation for setting backing fields #6266
Comments
@ajcvickers Let me know what you think of this design for the new attribute (I was thinking of putting it in EFCore.Abstractions next to namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Names the backing field associated with this property.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class BackingFieldAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="BackingFieldAttribute" /> class.
/// </summary>
/// <param name="name">The name of the backing field.</param>
public BackingFieldAttribute([NotNull] string name)
{
Check.NotEmpty(name, nameof(name));
Name = name;
}
/// <summary>
/// The name of the backing field.
/// </summary>
public string Name { get; }
}
} |
@dotnet/efcore Do people think this should be its own annotation? Or should we have one attribute for property mapping and facets? Or one attribute for property mapping, one for facets? |
What is property mapping? And which facets are we planning to add annotations for? |
Maybe we should make a list of all the things that can be configured for with the fluent API for which there are no attributes? |
Not sure this is exhaustive, but a quick look at the docs shows the following Fluent API with no attribute equivalent (note: some of these don't apply to properties and so may not be relevant here):
|
Notes from team discussion 2/19/20: For this particular issue we decided (at least for now) to use one attribute for |
This would allow a property to be annotated with a backing field directly in the class. One advantage of this is that the nameof() syntax could be used to reference the field.
The text was updated successfully, but these errors were encountered: