没有PK的实体框架一对多关系

时间:2014-09-12 20:26:38

标签: entity-framework ef-code-first

我有两个相关实体如下:

public class VehicleExtraEntity
{
    public int Id { get; set; }
    public Guid NameKey { get; set; }
    public virtual ICollection<WordEntity> WordsOfName { get; set; }
}

另一个实体:

public class WordEntity
{
    public int Id { get; set; }
    public string Content { get; set; }
    public Guid Key { get; set; }
}

我的目的是编写支持多语言的数据库表。例如;

WordEntity1 : {Id=1, Content="Child Seat", Key="abcdef-12456"}
WordEntity2 : {Id=2, Content="Çocuk Koltuğu", Key="abcdef-12456"} --> Same Key
VehicleExtraEntity1 : {Id=1, NameKey = "abcdef-123456"}

我尝试过流畅的api,但只支持与导航属性的关系。它希望我使用多对多的关系。但我想像上面所写的那样解决我的问题。

0 个答案:

没有答案