gpt4 book ai didi

c# - MVC3 中的 EntityCommandExecutionException

转载 作者:太空宇宙 更新时间:2023-11-03 14:01:13 24 4
gpt4 key购买 nike

我正在尝试使以下函数正常工作,但一直收到 EntityCommandExecutionException 错误。我不知道该错误是什么意思,并且一直在尝试解决该问题但无济于事。功能很基础...

    public Weeks getWeekById(int id)
{
Weeks week = database.Weeks.Where(w => w.id == id).SingleOrDefault();
return week;
}

在数据库中,我有一个名为 Weeks 的表,在这两个字段中,一个 int id 字段和一个字符串名称字段。我什至尝试过调用字符串的“getWeekByName”方法,但得到了同样的错误。我有很多函数在其他表上工作时具有完全相同的语法,例如... 公共(public)设施 getFacilityById(int id){ 设施 facility = database.Facilities.Where(f => f.id == id).SingleOrDefault(); 返回设施;

谁能告诉我到底出了什么问题以及我该如何解决它?

干杯

最佳答案

尝试更新实体模型。可能有帮助

关于c# - MVC3 中的 EntityCommandExecutionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10670018/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com