I'm new to entity framework technology and I just generated 3 classes from my tables:
I wanted to set a condition that the resource can't be used by two projects and I want that in my project's Add method how can I modify it, is it even possible to modify it?
public partial class Project
{
public int Id { get; set; }
public string Name { get; set; }
public Nullable<int> Resource { get; set; }
public Nullable<int> Manager { get; set; }
public Nullable<System.DateTime> StartDate { get; set; }
public Nullable<System.DateTime> Deadline { get; set; }
public Nullable<System.DateTime> EndDate { get; set; }
public virtual Emploee Emploee { get; set; }
public virtual Resource Resource1 { get; set; }
}
You can modify it but it will override when you generate again. Add partial class and put your method there.
//Your partial class
public partial class Project
{
public string DoCustomWork()
{
}
}
由于首先使用的是数据,因此,如果您希望资源对于单个项目是唯一的,则在项目表中的资源FK上创建唯一约束。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.