我生成了一个新的迁移,但由于某种原因,它删除了我正在使用的所有枚举,并且没有在 db 模式中添加对它的任何支持。虽然它是在 Code-First 中定义的
这些是我的枚举:
using System;
namespace StockManagement.Enums
{
public enum InventoryMethod
{
FIFO = 0,
LIFO = 1,
WEIGHTED_AVERAGE = 2
}
public enum TransactionDirection
{
BUY = 0,
SELL = 1
}
}
这些是我的 2 个相关课程:
public class User
{
[Key]
public int UserID { get; set; }
public string UserName { get; set; }
public string Email { get; set; }
public string Password { get; set; }
/// <summary>
/// FIFO = First In First Out
/// LIFO = Last In First Out
/// AVG = Average
/// </summary>
public InventoryMethod InventoryMethod { get; set; }
public virtual ICollection<Article> Articles { get; set; }
}
public class ArticleTransaction
{
[Key]
public int ArticleTransactionID { get; set; }
public DateTime TransactionDate { get; set; }
/// <summary>
/// Buy = Buying goods from suppliers
/// Sell = Selling goods to customers
/// </summary>
public TransactionDirection BuyOrSell { get; set; }
public int Number { get; set; }
public double PriceExclusive { get; set; }
public virtual Article Article { get; set; }
}
这是我生成的迁移:
using System.ComponentModel.DataAnnotations;
using System;
using StockManagement.Enums;
public class ArticleTransaction
{
[Key]
public int ArticleTransactionID { get; set; }
public DateTime TransactionDate { get; set; }
/// <summary>
/// Buy = Buying goods from suppliers
/// Sell = Selling goods to customers
/// </summary>
public TransactionDirection BuyOrSell { get; set; }
public int Number { get; set; }
public double PriceExclusive { get; set; }
public virtual Article Article { get; set; }
}
我有 EF 5.0,这最近没有改变 :) 任何人都知道为什么会突然发生这种情况以及如何解决这个问题?