Basic understanding of .netcore EFcore <two> shadow characteristics

Then on one. Add this method in the class MyEFTestContext

 protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Blog>()
                .Property<DateTime>("LastUpdated");
        }

After performing add-migration, the migration file will be generated

public partial class shadow : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<DateTime>(
                name: "LastUpdated",
                table: "Blog",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "LastUpdated",
                table: "Blog");
        }
    }

It can be seen after the update-database, add a field in the database, but not when EF general use, will not have access to.

Guess you like

Origin www.cnblogs.com/qgbo/p/11498946.html