【发布时间】:2020-12-13 12:37:54
【问题描述】:
我在 DataContext 上有以下代码:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration<CollectionSite>(new CollectionSiteMap());
modelBuilder.ApplyConfiguration<TestOrderAlcoholResult>(new TestOrderAlcoholResultMap());
//.... other configurations
modelBuilder.Entity<ButtonStyle>().HasData(new ButtonStyle()
{
Label = "Sharp edges",
Style = "border-radius: 0",
IsDefault = true,
Id = 1
});
modelBuilder.Entity<ColorScheme>().HasData(new ColorScheme()
{
Primary = "#a21521",
Secondary = "#fcf7f8",
Text = "#ced3dc",
Background = "#4e8097",
Shade = "#90c2e6",
IsDefault = true,
Id = 1
});
//.... seed other data
base.OnModelCreating(modelBuilder);
}
但update-database 之后的数据不会添加到表中。怎么了?
【问题讨论】:
标签: entity-framework entity-framework-core ef-core-2.2