Model column doesn't exist in __EFMigrationsHistory of EF Core

entity-framework entity-framework-core

Question

I am working with EF Core in Code-First approach. Everything is working well as like EF 6.0 for migration, creating tables, relationships, etc. But, one thing missing with __EFMigrationsHistory table, there should be a column 'Model' to store binary data of migration. Model column was not created when I run update-database command. Please check mine below codes and image.

enter image description here

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-Command:

Update-Database -Migration 20190703213515_FirstMigration
1
0
7/6/2019 10:56:21 AM

Popular Answer

In EF Core the __EFMigrationsHistory table has only two columns, so what is shown in your screenshot is correct.

When you run Update-Database it is not necessary to include the timestamp prefix of your migration. So if you added a migration named FirstMigration you may end up with a file 20190703213515_FirstMigration.cs, but what you want to run is this

Update-Database -Migration FirstMigration
0
7/7/2019 2:39:41 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow