如何设置嵌入类型的主键?

时间:2015-08-13 21:32:03

标签: c# entity-framework ef-code-first

我首先尝试通过Google.Apis.YouTube.v3.Data.Channel创建代码。

我的代码:

modelBuilder.Entity<ChannelBrandingSettings>().Property(x => x.ETag);

modelBuilder.Entity<Google.Apis.YouTube.v3.Data.Channel>().Map(m =>
{
    m.MapInheritedProperties();
    m.ToTable("Youtube_Archieve");
}); 

但是当我尝试更新数据库时,我得到了错误:

YoutubeAdv.Models.ChannelBrandingSettings: : EntityType 'ChannelBrandingSettings' has no key defined. Define the key for this EntityType.
YoutubeAdv.Models.PropertyValue: : EntityType 'PropertyValue' has no key defined. Define the key for this EntityType.
YoutubeAdv.Models.ImageSettings: : EntityType 'ImageSettings' has no key defined. Define the key for this EntityType.
YoutubeAdv.Models.LocalizedProperty: : EntityType 'LocalizedProperty' has no key defined. Define the key for this EntityType.
YoutubeAdv.Models.LocalizedString: : EntityType 'LocalizedString' has no key defined. Define the key for this EntityType.

0 个答案:

没有答案