Here we use Entity Framework 6 with MVC5.
- First here is our SQL table:
- So for this tutorial first we will create a new empty MVC application. In this we will add an ADO.Net entity data model to the Model as in the following:
- Select "EF Designer from database".
- Then select Server name and Database name.
- Select the Yes radio button and click on "Next".
- Select "Entity Framework 6.x".
- Then select the table.
- Now MVCdb.edmx has been added to the Model folder.
- Now add an Employee Controller as in the following:
- Choose "MVC5 Controller with views, using Entity Framework".
- Select Model class and DataContextClass and provide the Controller name Employee.
- So now, automatically create an Index, Create, Delete, Edit and Details Views and Controller actions.
- Now run the application (Ctrl+F5).
- Click on "Create New".
- Add data and click on the Create button.