dynamically add menu and submenus in asp.net mvc using entity framework | Tutorial

For Consultation : +91 9887575540

Stay Connected :

Spread the love

In this example, I am going to create two  tables(MainMenu, SubMenu)

Database Script for database tables

Insert some Dummy Data to Show 

Create New ASP.NET MVC Web application Project

  1. Create a new Project. Open Visual Studio 2013.
  2. Go to “File” => “New” => “Project…”.
  3. Select “Web” in installed templates.
  4. Select “ASP.NET MVC Web Application”.
  5. Enter the Name and choose the location.
  6. Click “OK”.

In this example, I am going to use Entity Framework code first approach so we have to create two model classes for mainmenu and submenu tables and one data context for table mappings.



Model2.cs(Data Context Class)

Pass Connection String in Web.config

Create New Controller(HomeController) and write Index action and attach view with index action



Download Source Code