【发布时间】:2015-03-26 09:24:46
【问题描述】:
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。 我可以创建更多同名的运动,但我不喜欢这样
我的运动名称如何才能唯一?请帮我。谢谢
【问题讨论】:
-
I can create a more sports with a same name, but i don't like this这是什么意思?在数据库中创建它们?这里需要更多信息。
标签: c# asp.net-mvc unique