Моя модель:
public class Product
{
...
public decimal Fineness { get; set; }
...
}
Посещение базы данных:
new List<Product>
{
new Product { ..., Fineness = 0.757M, ... },
new Product { ..., Fineness = 0.674M, ... },
new Product { ..., Fineness = 0.475M, ... }
}.ForEach(p => context.Products.Add(p));
Запрос базы данных для проверки посева:
var products = db.Products.ToList();
foreach (var p in products)
{
S.D.Debug.WriteLine("ProductList: {0}, {1}", p.Name, p.Fineness);
}
Выход консоли:
ProductList: Test Product, 0.75
ProductList: Test Product, 0.67
ProductList: Test Product, 0.47
Я делаю что-то действительно глупое или что-то??? Все усекается до 2 знаков после запятой.
Решение - благодаря Патрику:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>().Property(x => x.Fineness).HasPrecision(10, 5);
}