This question is locked. New answers and comments are not allowed.
hi, first time here..
i have a project with sqlserver database but no reference foreign key. So now i have changed my project to add the constraint of reference with foreign key to the database tables as below:. e.g.
ALTER TABLE Staffs
Add CONSTRAINT fk_Staffs FOREIGN KEY(UserId) REFERENCES Users(Id);
But i don see the benefit after i added the foreign key.. the tables are all linked up now in my .dbml but when i try to write this..
this.Users.Staff , the staff is always null ... do i still have to initialize that staff eventhough all tables are already linked up?
In my Users.cs form,
1) Do i still have to declare public Staff Staff { get; set; } in Users class?
2) Do i have to initialize the this.Staff in OnCreated?
Also partial void OnCreated()
{
this.Staff = new Staff();
//this.CourseTutor = new CourseByTutor();
// this.CourseUserStatus = new CourseUserStatuse();
//this.Payment = new Payment();
//this.Payment.SaleOrderItem = new SaleOrderItem();
//this.Payment.SaleOrderItem.SaleOrder = new SaleOrder();
// this.SaleOrder = new SaleOrder();
}
All the commented code are written previously before i add reference foreignkey..so after i add the reference foreign key, do i still need that?