0

我最初创建了一个包含这些列的表。

我有以下类,它已经由数据库中的迁移创建。

public class Products
{
    [Key]
    public int ProductId { get; set; }

    public string ProductName { get; set; }

    public string ShotDescription { get; set; }

    public decimal OldPrice { get; set; }

    public decimal NewPrice { get; set; }

    public bool DisableBuyButton { get; set; }

    public bool DisableWishListButton { get; set; }

    public bool ShowForPrice { get; set; }


    public bool NotReturnable { get; set; }

    public int MinimumCartQty { get; set; }

    public int MaximumCartQty { get; set; }

    public string SKU { get; set; }


    public bool ShippingEnabled { get; set; }

    public decimal Weight { get; set; }

    public decimal Length { get; set; }

    public decimal Width { get; set; }

    public decimal Height { get; set; }

    public string Categories { get; set; }

    public string ManufacturerPartNumber        { get; set; }

    public DateTime AvailableDate { get; set; }

    public DateTime AvailableEndDate { get; set; }

    public string AdminComment { get; set; }

    public DateTime CreatedOn { get; set; }

    public DateTime UpdatedOn { get; set; }


    public Boolean DisplayAvailability { get; set; }

    public DateTime ExpectedDateBackOnStock { get; set; }

    public bool IsOnBackOrder { get; set; }

    public int Warehouse { get; set; }

    public int BinNumber { get; set; }

    public int IlseNumber { get; set; }



    public bool IsGiftCard { get; set; }

    public bool IsDownloadableProduct { get; set; }

    public bool IsRental { get; set; }


    public string SeoDescription { get; set; }


    public int   Stock { get; set; }

    public int PropertyImageId { get; set; }

}

我使用以下命令创建迁移,然后更新数据库。

Add-Migration InitialCreate

Update-Database

但是,当我向它添加一个新列时,即使它现在在新类中,它也不会将用户 id 列提交到表中,它不会产生任何错误,只是在包管理控制台中说完成但它没有添加列到数据库上的表中。有人可以告诉我我可能做错了什么谢谢。有问题的领域是

公共 Guid 用户 ID { 获取;放; }

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace solitude.models.Models
{
    public class Products
    {
        [Key]
        public int ProductId { get; set; }

        public string ProductName { get; set; }

        public string ShotDescription { get; set; }

        public decimal OldPrice { get; set; }

        public decimal NewPrice { get; set; }

        public bool DisableBuyButton { get; set; }

        public bool DisableWishListButton { get; set; }

        public bool ShowForPrice { get; set; }


        public bool NotReturnable { get; set; }

        public int MinimumCartQty { get; set; }

        public int MaximumCartQty { get; set; }

        public string SKU { get; set; }


        public bool ShippingEnabled { get; set; }

        public decimal Weight { get; set; }

        public decimal Length { get; set; }

        public decimal Width { get; set; }

        public decimal Height { get; set; }

        public string Categories { get; set; }

        public string ManufacturerPartNumber        { get; set; }

        public DateTime AvailableDate { get; set; }

        public DateTime AvailableEndDate { get; set; }

        public string AdminComment { get; set; }

        public DateTime CreatedOn { get; set; }

        public DateTime UpdatedOn { get; set; }


        public Boolean DisplayAvailability { get; set; }

        public DateTime ExpectedDateBackOnStock { get; set; }

        public bool IsOnBackOrder { get; set; }

        public int Warehouse { get; set; }

        public int BinNumber { get; set; }

        public int IlseNumber { get; set; }



        public bool IsGiftCard { get; set; }

        public bool IsDownloadableProduct { get; set; }

        public bool IsRental { get; set; }


        public string SeoDescription { get; set; }


        public int   Stock { get; set; }

        public int PropertyImageId { get; set; }


        public Guid UserId { get; set; }  


    }
}
4

0 回答 0