当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Constraint exception unhandled by user code - help debug please

问题描述:

I have a DB table with some nullable columns. I am developing DB first, and created an EDMX file to model the database. Using MVC4 framework.

I then scaffolded a controller and view as normal, but when I run the web application to test, I am faced with the following Constraint exception...

The 'EURam' property on 'FixHistory' could not be set to a 'null' value. You must set this property to a non-null value of type 'Decimal'.

and this points to the following scaffolded code within the controller:

 public ActionResult Index()

{

var fixhistories = db.FixHistories.Include(f => f.Metal);

return View(fixhistories.ToList());

}

Now I need the data for that column to be nullable - sometimes the data exists, sometimes it doesn't...

How do I fix this?

I appreciate that this may be a simple question, but I am a complete Microsoft Noob.

分享给朋友:
您可能感兴趣的文章:
随机阅读: