After creating our Model, Repository, and Unit of Work; we get back to where we left off to continue the ASP MVC app SamuraiListing development. Before we start, here’s the link to the source code that we have create so far. Using this source code, here’s a step by step guide to add database to our project.
1. Add Database to ASP MVC 4 project.
Copy the database file we created in SamuraiListing.Data project and paste it to SamuraiListing project under “App_Data” folder.
2. Reference our Model, Repository and Unit of Work class to ASP MVC.
On SamuraiListing project, Right click on References folder > Add SamuraiListing.Data.
3. Edit Web.config connection string
Copy the DatabaseContext connection string from SamuraiListing.Data App.Config file and paste it into SamuraiListing Web.Config file.
<connectionStrings> LocalDb)\v11.0;Initial Catalog=aspnet-SamuraiListing-20121128100409;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SamuraiListing-20121128100409.mdf" /> LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Database.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings>
Up to here, we have successfully added the database into our ASP MVC project. Right click on the database > Open will bring you the database without any problem.
Next up is to add KendoUI Grid to our App and perform CRUD using our Unit of Work class.
Important Note:
You are looking at one of the blog post I completed in a tutorial series about KendoUI and ASP MVC4, you can find out the Table of Content on - Simple KendoUI Example – SamuraiListing
Step 1 – How to create KendoUI ASP MVC 4 project.
Step 2 - How to Create a SQL Database Project for ASP MVC in Visual Studio 2012
Step 3 - How to create a simple data access layer using Repository Pattern with Entity Framework
Step 4 - How to create a simple data access layer Unit of Work pattern with Entity Framework
Step 5 - How to add Database and DataModel class to ASP MVC4 project.
Step 6 - How to add KendoUI Grid Control and perform CRUD with ASP MVC.
Pingback: Simple KendoUI Example – SamuraiListing | BizVise - Melaka Software Development