我正在尝试访问具有 State = added 的实体的 Navigational 属性,但 Navigational 属性为空。
using (var myc = new DBTestEntities())
{
var cust = new Customer();
cust.CustomerName = "New Customer";
cust.BusinessTypeID = 1; // This is a valid BusinessTypeID present in BusinessType table
myc.Customers.Add(cust);
// at this point cust.BusinessType is null
Console.WriteLine(cust.BusinessType.BusinessTypeName);
}
在这种情况下,任何人都可以指导我如何访问 Navigational 属性。