【发布时间】:2019-07-07 10:39:41
【问题描述】:
我正在以代码优先的方式使用 EF Core。一切都像 EF 6.0 一样运行良好,用于迁移、创建表、关系等。但是,__EFMigrationsHistory 表缺少一件事,应该有一个“模型”列来存储迁移的二进制数据。运行 update-database 命令时未创建模型列。请检查我下面的代码和图片。
DbContext
namespace ProfileCore.DataAccess
{
/// <summary>
/// Represents DB Context (DbSet, Configuration and common activities)
/// </summary>
public partial class ProfileCoreDbContext: DbContext, IDbContext
{
#region Ctor
public ProfileCoreDbContext(DbContextOptions<ProfileCoreDbContext> options) : base(options)
{
}
#endregion
#region Authentications DbSets
public virtual DbSet<UserType> UserType { get; set; }
#endregion
#region Utilities
/// <summary>
/// Further configuration the model
/// </summary>
/// <param name="modelBuilder">The builder being used to construct the model for this context</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
#endregion
}
}
更新命令:
Update-Database -Migration 20190703213515_FirstMigration
【问题讨论】:
-
“EF Core 中是否弃用了模型列?” 不知道您为什么关心,但看起来确实如此。和现在的操作系统开发一样,没有太多相关文档,可以从HistoryRow类的属性中获取默认列。
标签: entity-framework entity-framework-core