I have this weird issue wherein when I add new values to database. suppose to be I expected also that the navigational properties will have data after UnitOfWork.SaveChanges()
.
Heres my model:
[Column("Client_ID"), Key]
public int ClientID{ get; set; }
[Column("Employee_ID"), Required]
public int EmployeeID { get; set; }
[ForeignKey("EmployeeID")]
public virtual Employee201 Employee { get; set; }
On save changes only the ClientID updated the values not the Employee with foreign key. Am I lacking something here?
Repository method
public Client Create(Client client )
{
if (client != null)
{
GetDbSet<Client >().Add(client );
UnitOfWork.SaveChanges();
}
return client ;
}
Update
Now i found the issue. when im adding new data im using new Client() this result to entity type only and not proxy type. Is there a way to convert this when im using new Client() that it should always be proxy type?