Entity framework 用于建模的非基本数据类型?

Entity framework 用于建模的非基本数据类型?,entity-framework,asp.net-mvc-4,ef-code-first,migration,ado.net-entity-data-model,Entity Framework,Asp.net Mvc 4,Ef Code First,Migration,Ado.net Entity Data Model,我想在我的歌曲实体中使用“TagLib.Tag”数据类型。 当我尝试启用迁移时,我得到: public class Song { public int SongID { get; set; } public string URL { get; set; } public virtual TagLib.Tag SongInfo { get; set; } } 如何在模型中使用外部复杂数据类型?我看到关于标记实体类的错误,您没有为此键

我想在我的歌曲实体中使用“TagLib.Tag”数据类型。 当我尝试启用迁移时,我得到:

public class Song
    {
        public int SongID { get; set; }
        public string URL { get; set; }
        public virtual TagLib.Tag SongInfo { get; set; }
    }

如何在模型中使用外部复杂数据类型?

我看到关于标记实体类的错误,您没有为此键属性定义

也许您的代码如下所示:

One or more validation errors were detected during model generation:

\tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'XmpNode' has no key defined. Define the key for this EntityType.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Exif_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Exif_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'XmpTag_NodeTree_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Xmp_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Xmp_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_OtherTags_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_OtherTags_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_AllTags_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_AllTags_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'XmpNodes' is based on type 'XmpNode' that has no keys defined.
\tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'Tags' is based on type 'Tag' that has no keys defined.
public class Tag
{
    public string TagName{get; set;}
    // other fields
}
您必须按以下方式进行更改:

One or more validation errors were detected during model generation:

\tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'XmpNode' has no key defined. Define the key for this EntityType.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Exif_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Exif_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'XmpTag_NodeTree_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Xmp_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_Xmp_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_OtherTags_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_OtherTags_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_AllTags_Source' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: : The referenced EntitySet 'Tags' for End 'CombinedImageTag_AllTags_Target' could not be found in the containing EntityContainer.
\tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'XmpNodes' is based on type 'XmpNode' that has no keys defined.
\tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'Tags' is based on type 'Tag' that has no keys defined.
public class Tag
{
    public string TagName{get; set;}
    // other fields
}

请添加Taglib.Tag类详细信息