c# - How to map a 1:1 (optional) mapping in Entity Framework -
i have class like:
public class employee { [column("employee_id")] public int employeid {get;set;} } public class location { [column("employee_location_id")] public int id {get;set;} [column("employee_id")] public int employeeid {get;set;} }
on employee class, added virtual property:
public virtual location location {get;set;}
i trying add optional property (lazy loaded), employee may have or or 1 location.
i'm getting error when mvc application loads now:
system.data.sqlclient.sqlexception: invalid column name 'location_id'.
have tried specifying fk/navigation properties explicitly?
public int locationid { get; set; } [foreignkey("locationid")] public virtual location location { get; set; }
navigation property not loading when id of related object populated
Comments
Post a Comment