I've created a sample project which you can download here.
Steps to recreate manually:
- Create new MVC3 web project.
- Add a .edmx
- Create an Entity named 'Account.'
- Create an Entity named 'AccountLineItem.'
- Add a Decimal field to 'AccountLineItem.'
- Create a one-to-many association between 'Account' and 'AccountLineItem', be sure to leave checked the option to create a navigation property on 'Account.'
Add the code to update the DB anywhere, I used Index() on the HomeController:
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; using (var db = new TestStoreContainer()) { Account acc = new Account(); acc.Name = "Test Account"; AccountLineItem accItem = new AccountLineItem(); accItem.Amount = 22.10M; acc.AccountLineItems.Add(accItem); db.Accounts.AddObject(acc); db.SaveChanges(); } return View(); }
As you can see, I am updating the DB with an Account, and an AccountLineItem with a Value of 22.10; However, after running this code, the value of 22 appears in SQLEXPRESS with no precision.
I discovered this behavior using a SQL 2008 R2 box, so I don't believe the issue is with Express.
Can anyone else replicate this behavior? Am I doing something blatantly wrong? All feedback is welcome.