c# - Is having only a FK Reference preferable to having both the object reference and the FK reference? -


i trying take advantage of julie lerman calls bounded context. domain models have employee, customer, inventoryitems, salesorderheader & salesorderdetail. sales order header has 2 properties:

public guid employeeid { get; set; }  [foreignkey("employeeid")] public virtual employee salesperson { get; set; } 

now sales order context has no need know employee’s social security number nor salary, etc. created employeereference model such:

[table("employees")] public class employeereference {     [key]     public guid id { get; set; }      [stringlength(25, minimumlength = 3)]     public string firstname { get; private set; }      [stringlength(25, minimumlength = 3)]     public string lastname { get; private set; }      public string fullname => string.format("{0} {1}", firstname, lastname); } 

to make bounded context sales orders include salesorderheader, salesorderdetail, inventoryitems, customer & employeerefererence while ignoring employee table.

now error sales order headers employee object cannot map null.

my solution comment out property salesperson in sales order header leave employeeid, run entityframework migration.

because salesperson property virtual can not override property? having id reference preferable having both object reference , id reference?


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -