0
鑑於此代碼第一個數據模型共享密鑰,如何將我配置或實現對Product
實體LocalizedName
導航屬性,使用上Product
實例LocalNameKey
屬性的關鍵之一,而_languageId
從上下文中作爲其他關鍵?導航屬性與EF代碼第一
public class SampleDataContext : DbContext
{
int _languageId;
public SampleDataContext(int languageId)
{
_languageId = languageId;
}
public DbSet<LocalizedName> LocalNames { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<Language> Languages { get; set; }
}
public class LocalizedName
{
[Key, Column(Order = 0)]
public Guid Key { get; set; }
[Key, Column(Order = 1)]
public int LanguageId { get; set; }
public string Name { get; set; }
}
public class Language
{
public int Id { get; set; }
public string Name{ get; set; }
}
public class Product
{
public int Id { get; set; }
public string Sku { get; set; }
public Guid LocalNameKey { get; set; }
}
好吧,我想我明白爲什麼這是不可能的。感謝關於本地化數據的負責人。 –