What is "Data Context class" when using Entity Framework to create a controller with read/write actions and views?

asp.net asp.net-mvc asp.net-mvc-3 c# entity-framework

Question

So in Visual Studio, when I go to add a controller, I get this dialog:

enter image description here

I was curious what Visual Studio would create if I chose "Controller with read/write actions and views, using Entity Framework", as I'm using EF.

So I set my Model class to a view model created, chose Razor for my views, but I don't know what Data context class is? The only thing in the dropdown is my view model I created.

1
22
5/16/2011 12:14:55 AM

Accepted Answer

The Data Context class is the top level EF object, the one that contains all your collections of entities that map to tables in the database.

The controller needs to be able to access this so that it can perform CRUD operations.

28
5/16/2011 12:35:43 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow