<分区>
public class Sport
{
public int SportID { get; set; }
[Required(ErrorMessage = "The Name field is required.")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[StringLength(50, MinimumLength = 3)]
public string Name { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
[Display(Name = "Start Date")]
public DateTime StartDate { get; set; }
[Column(TypeName = "money")]
public decimal Price { get; set; }
public int? InstructorID { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
public virtual ICollection<Instructor> Instructors { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
此表中的关键字是 SportID。 我可以创建更多同名运动,但我不喜欢这个
如何让我的运动名称唯一?请帮我。谢谢