using System.Diagnostics.CodeAnalysis; namespace System.ComponentModel.DataAnnotations.Schema { /// /// Specifies how the database generates values for a property. /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "We want users to be able to extend this class")] public class DatabaseGeneratedAttribute : Attribute { /// /// Initializes a new instance of the class. /// /// The pattern used to generate values for the property in the database. public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption) { if (!(Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption))) { throw new ArgumentOutOfRangeException("databaseGeneratedOption"); } DatabaseGeneratedOption = databaseGeneratedOption; } /// /// The pattern used to generate values for the property in the database. /// public DatabaseGeneratedOption DatabaseGeneratedOption { get; private set; } } }