我有两个实体:学生和班级。
他们之间有多对多的关系:
class Student
{
ICollection<Class> Classes{get;set;}
}
class Class
{
ICollection<Student> Students{get;set;}
}
当我尝试执行以下语句时:
return _db.Students.Where(s => s.Email == email).FirstOrDefault();
我收到此错误消息:
"The context cannot be used while the model is being created."
当我忘记将连接字符串从项目中的 app.config 放置到运行应用程序并引用 CF 的 webui 项目中的 web.config 时,我遇到了同样的问题/异常。
也许不是你的情况,但值得检查。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)