neeraj gandhi

neeraj gandhi

  • 1.4k
  • 299
  • 57.3k

Entity Framework

May 23 2017 11:54 PM
 i have two class employee and department
 
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
// navigation property 
public  Department department{get;set;}
}
public class Department
{
public int ID { get; set; }
public string Department { get; set; }
// navigation property
public Employee employee{get;set;}
 
}
 
// this is the property i have set for one to one relation ship  
this.HasRequired<Department>(dep => dep.department).WithOptional(emp => emp.employee).WillCascadeOnDelete(false); 
 
but when i check in sql server i dont find a column in employee table
which refernce to forgein key column of department .
 
 hence during insert in sql server i get error  forgein key error 
 
 
 

Answers (3)