ObjectContext for a Linq query in a DynamicData websitehttp://forums.asp.net/t/1755469.aspx/1?ObjectContext+for+a+Linq+query+in+a+DynamicData+websiteWed, 04 Jan 2012 02:49:05 -050017554694762732http://forums.asp.net/p/1755469/4762732.aspx/1?ObjectContext+for+a+Linq+query+in+a+DynamicData+websiteObjectContext for a Linq query in a DynamicData website <p>Hi,</p> <p>I created my first Dynamic Data 4 web site, with the model-first approach. I created my model (MyModel.edmx), my entities (Employee, Project, Client, etc.) and my SQL Server database,&nbsp;and I also registered the DataContext in global.asax and&nbsp;allowed scaffolding for all the entities.</p> <p>Everything works fine.</p> <p>Now, in a custom page, I only want to execute a linq query, i.e.: var&nbsp;q =&nbsp;from e in context.Employee where e.Name = &quot;Tom&quot; select e;</p> <p>But... the &quot;context&quot; variable? Visual Web Developer created a MyModelContainer class derived from ObjectContext, but if I try to use it the editor tells me that MyModelContainer &quot;does not contain a definition for Employee&quot;.</p> <p>My question is: how I get the right ObjectContest to use in my linq queries?</p> 2012-01-03T20:48:39-05:004762974http://forums.asp.net/p/1755469/4762974.aspx/1?Re+ObjectContext+for+a+Linq+query+in+a+DynamicData+websiteRe: ObjectContext for a Linq query in a DynamicData website <p>The correct syntax to get the context is MyModelContainer contex = new MyModelContainer().</p> 2012-01-04T02:49:05-05:00