我生成了一个新的迁移,但由于某种原因,它会删除我使用的所有枚举,并且不会在数据库模式中为其添加任何支持。虽然在代码优先EF 5.0迁移删除枚举
的定义,这些都是我的枚举:
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,这最近没有变化:) 任何人都有一个想法,为什么th是突然发生,如何解决这个问题?
您生成的迁移是怎样的?你使用的是什么版本的.NET? –
等一下,EF5做/做到了吗?我以为我读过的地方是,对枚举的数据库级支持不是内置的,它只处理数字字段作为它们的后备存储。 –