是否建议使用 [Required]
属性来播种数据?
更具体的让我们举这个例子
public class Equipment : BaseEntity
{
#region Properties
public int EquipmentId { get; set; }
[Required]
public string EquipmentName { get; set; }
public EquipmentType EquipmentType { get; set; }
#region Navigation Properties
public ICollection<EventEquipment> EventEquipments { get; set; }
#endregion
#endregion
#region Constructors
public Equipment()
{
}
#endregion
#region Methods
#endregion
}
}
我可以使用 EquipmentName
属性来播种数据吗?这是推荐的方法吗?
如果不是,用于播种数据的最佳属性是什么?
最佳答案
如果你想播种数据,更好的方法是播种整个对象,而不仅仅是单个属性。另一方面,对种子所需的属性没有正式限制。
关于c# - 我可以在 EF 中播种所需属性的数据吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42789763/