Adding a controller with read/write actions and views, using Entity Framework - what is "Data Context class"?

29,696

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.

Share:
29,696

Related videos on Youtube

Steven
Author by

Steven

Updated on July 09, 2022

Comments

  • Steven
    Steven almost 2 years

    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.

  • Steven
    Steven almost 13 years
    The Data Context class is the top level EF object - Would that be my .edmx file?
  • Chris Sainty
    Chris Sainty almost 13 years
    The class generated from it. You should be using it any time you are writing code that talks to the database. The dialog appears to have selected the correct class, what is wrong with the generated code?
  • Steven
    Steven almost 13 years
    That image was from a tutorial I was going through, it's not my code. But I see what you're saying now, thanks.