How To Create A Dbcontext Class In Mvc
-
- Updated date Nov 01, 2019
- 41.6k
- 4
In this blog, you will learn about using DBContext Connect Database in ASP.NET MVC 5.
Continuing with the previous article, today, I'm sharing a simple example using DBContext Connect Database in ASP.NET MVC 5. You can see my previous blogs below Installing Entity Framework 6.x Tools->Nuget Package Manager Entity Framework It helps us to map relationship object in the database used in ADO.NET Okay, we need to create a database in App_Data directory, so you right clickApp_Data->New Item After that, you open Web.config in the project and add the below code to connect database. Create models in ASP.Net MVC 5 In the picture above, we create a User table, so I will build the entity model for the User. Click Models-> add class User.cs Create Class Connect Database extends DBContext DBcontext is used in Entity Framework, it's a very important part to connect to a table in database and execute query (insert, update, delete) Models/demoEntities.cs base("demoASPEntities") The declaration name connect. DbSet Users We use the declaration table Users Controllesr/HomeController.cs Views/Home/Index.cshtml edits the code below, Demo
How To Create A Dbcontext Class In Mvc
Source: https://www.c-sharpcorner.com/blogs/asp-net-mvc-5-using-dbcontext-connect-database
Posted by: kennedyliaboarpood.blogspot.com
0 Response to "How To Create A Dbcontext Class In Mvc"
Post a Comment