我最初创建了一个包含这些列的表。
我有以下类,它已经由数据库中的迁移创建。
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列提交到表中,即使它现在在新类中它没有产生错误,只是在包管理控制台中说完了但是它有没有将列添加到数据库的表中。有人可以告诉我,我可能做错了什么,谢谢。有问题的领域是
public Guid UserId {get;组; }
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; }
}
}