ModelValidationException是未处理的用户代码,(plz help) [英] ModelValidationException was unhandled user code, (plz help)

查看:107
本文介绍了ModelValidationException是未处理的用户代码,(plz help)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public int GetCount()
        {
            ShoppingCartId = GetCartId();

            // Get the count of each item in the cart and sum them up          
            int? count = (from cartItems in _db.ShoppingCartItems
                          where cartItems.CartId == ShoppingCartId
                          select (int?)cartItems.Quantity).Sum();
            // Return 0 if all entries are null         
            return count ?? 0;
        }





你能否帮我解决以下错误,我查了一切没有ID错误



ModelValidationException未由用户代码处理



EntityFramework中出现'System.Data.Entity.ModelConfiguration.ModelValidationException'类型的异常.dll但未在用户代码中处理



附加信息:在模型生成期间检测到一个或多个验证错误:



Can you help me on the following error, i checked everything no ID mistakes

ModelValidationException was un handled by user code

An exception of type 'System.Data.Entity.ModelConfiguration.ModelValidationException' occurred in EntityFramework.dll but was not handled in user code

Additional information: One or more validation errors were detected during model generation:

推荐答案

U need to set primary key of ur table in database and Key in model class


检查你的表必须有记录



:)
Check you table It must has records

:)


这篇关于ModelValidationException是未处理的用户代码,(plz help)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆