我生成了一個新的遷移,但由於某種原因,它會刪除我使用的所有枚舉,並且不會在數據庫模式中爲其添加任何支持。雖然在代碼優先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做/做到了嗎?我以爲我讀過的地方是,對枚舉的數據庫級支持不是內置的,它只處理數字字段作爲它們的後備存儲。 –