开发者

EF CTP4 : "The context cannot be used while the model is being created."

开发者 https://www.devze.com 2023-02-18 16:28 出处:网络
I have two entities : Student and Class. they have a many-to-many relationship between each other : class Student

I have two entities : Student and Class.

they have a many-to-many relationship between each other :

class Student
{
   ICollection<Class> Classes{get;set;}
}

class Class
{
   ICollection<Student> Students{get;set;}
}

when I try to execute the following statement :

return _db.Students.Where(s => s.Email == email).FirstOrDefault();

I get this error message :

 "The context cannot be used while the开发者_开发问答 model is being created."


I had same issue/exception when I forgot to put connection string from the app.config in project where codefirst model was to web.config in webui project from where I was running my app and referenced CF. Maybe not your case, but worth checking.

0

精彩评论

暂无评论...
验证码 换一张
取 消