1.

Write the steps to retrieve data from database using Entity Framework in MVC.

Answer»

The following steps will SHOW you how to retrieve DATA from a database in MVC (Model View Controller) using Entity Framework: 

  • As a first step, we MUST create a new project.
  • The next step is to add an Entity Framework reference from the NuGet package manager.
  • Then, a new class has to be created within the model inside the table structure.
  • After that, we are required to add a connection STRING in the web.config.connection. It should be MATCHED with the context.
  • The next step is to open the Global.asax.cs class and add the new namespace of EF. We must then initialize the database.
  • You will now need to right-click on the Controller folder and add a new controller, followed by a model reference in the section namespace.
  • Last but not least, right-click on the controller's name and add the sections you want to retrieve.


Discussion

No Comment Found