stuck in EF migration limbo

后端 未结 7 1513
慢半拍i
慢半拍i 2020-12-20 10:58

i have somehow gotten my EF5 project into a state where I can\'t proceed.

When I do an \'update-database\' i get:

Unable to update database to

7条回答
  •  一生所求
    2020-12-20 11:44

    I did mistake in creation database

        using System.ComponentModel.DataAnnotations;
        using System.Globalization;
        namespace ProductsManager.Models
        {
            public class Product
            {
                public int ProductId { get; set; }
                public string Name { get; set; }
                public string Description { get; set; }
                public string Production { get; set; }
                public string Size { get; set; }
                public decimal<--- Price { get; set; }
                public string Barcode { get; set; }
            }
        }
    

    after add-migration Initial I realized and changed code to public int Price { get; set; } did same add-migration DummyMigration and its created in migration folder 080372472_dummyMigration

    namespace IdetityBeta.Migrations
    {
        using System;
        using System.Data.Entity.Migrations;
    
        public partial class DummyMigration : DbMigration
        {
            public override void Up()
            {
                AlterColumn("dbo.Products", "Price", c => c.String());
            }
    
            public override void Down()
            {
                AlterColumn("dbo.Products", "Price", c => c.Decimal(nullable:             false, precision:              18, scale: 2));
            }
        }
    }
    

    So then update-database and problem was solved

提交回复
热议问题