{"id":4589,"date":"2023-02-27T13:10:36","date_gmt":"2023-02-27T13:10:36","guid":{"rendered":"https:\/\/isophal.com\/?p=4589"},"modified":"2023-02-27T13:16:37","modified_gmt":"2023-02-27T13:16:37","slug":"entity-framework-new-database-first-tutorial-with-asp-net-5-for-beginners","status":"publish","type":"post","link":"https:\/\/isophal.com\/news\/2023\/02\/27\/4589.html\/","title":{"rendered":"Entity <strong>Framework\u00a0<\/strong>&#8211; New Database First Tutorial With ASP.NET 5 For Beginners"},"content":{"rendered":"\n<p>In this chapter, we will learn&nbsp;<strong>Entity Framework 6<\/strong>&nbsp;with a new database with the help of easy programming example. We will create a demo Entity Framework Project here and explain all the steps briefly so you can understand it clearly. Before starting this chapter, following knowledge is required.<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;Basic knowledge of ASP.Net MVC<br><strong>2.<\/strong>&nbsp;SQL Server 2005\/2008\/2012<br><strong>3.<\/strong>&nbsp;C# Programming Language<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">I. ABOUT THIS CHAPTER<\/h3>\n\n\n\n<p>Here, I am going to create a simple&nbsp;<strong>MVC 5 project<\/strong>&nbsp;with the help of&nbsp;<strong>Entity Framework 6<\/strong>. This project will do the following thing.<\/p>\n\n\n\n<p><strong>1.<\/strong>\u00a0One Page Design<br><strong>2.<\/strong>\u00a0Create Database and Table<br><strong>3.<\/strong>\u00a0Accept Entries from the User.<br><strong>4.<\/strong>\u00a0Save them to database<br><strong>5.<\/strong>\u00a0Display Data<br><strong>6.<\/strong>\u00a0Edit Data<br><strong>7.<\/strong>\u00a0Update Data<br><strong>8.<\/strong>\u00a0Delete Data<\/p>\n\n\n\n<p>After finishing project, your application will look like:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/Webp.net-gifmaker.gif\" alt=\"EF - Database First Output\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">II. Start A New ASP.NET Web Application (.NET Framework) Project<\/h2>\n\n\n\n<p>Here, I am using Visual Studio 2015 but you can use any of VS 2010\/2012\/2015 or 2017 version. You just have to create any version of MVC Project.<\/p>\n\n\n\n<p>There are 5 parts in this project and this is 2nd Part.<\/p>\n\n\n\n<p>PART 2:<\/p>\n\n\n\n<p><strong>PART 1.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/ef-new-database-first-tutorial-with-asp-net-5-for-beginners.php\">EF \u2013 New Database First Overview<\/a><br><strong>PART 2.<\/strong>Start a New ASP.NET MVC Project<br><strong>PART 3.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/create-new-database-and-table-for-entity-framework.php\">Create New Database and Table for EF<\/a><br><strong>PART 4.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/install-entity-framework-and-create-entity-data-model.php\">Install Entity Framework and Create Entity Data Model<\/a><br><strong>PART 5.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/mvc-5-crud-operation-using-entity-framework-6.php\">CRUD Operation using Entity Framework 6<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 1:<\/h3>\n\n\n\n<p>Open&nbsp;<strong>Visual Studio 2015<\/strong>&nbsp;and&nbsp;<strong>Start a New Project<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture.png\" alt=\"EF New Project\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 2:<\/h3>\n\n\n\n<p>Select&nbsp;<strong>Web<\/strong>&nbsp;in the left panel and then select&nbsp;<strong>ASP.NET Web Application (.NET Framework)<\/strong>&nbsp;from middle panel. Give Project Name&nbsp;<strong>FirstEFProject<\/strong>&nbsp;and click&nbsp;<strong>OK<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-1.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-1.png\" alt=\"EF New Project\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 3:<\/h3>\n\n\n\n<p>Select&nbsp;<strong>MVC<\/strong>&nbsp;in template window and change authentication to&nbsp;<strong>No Authentication<\/strong>&nbsp;and click&nbsp;<strong>OK<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/7.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/7.png\" alt=\"EF New Project\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">III. Create New Database And Table For Entity Framework<\/h2>\n\n\n\n<p>This project is about storing and retrieving Book Details in the library so we will create database and table according to the project.<\/p>\n\n\n\n<p>There are 5 parts in this project and this is 3rd Part.<\/p>\n\n\n\n<p>PART 3:<\/p>\n\n\n\n<p><strong>PART 1.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/ef-new-database-first-tutorial-with-asp-net-5-for-beginners.php\">EF \u2013 New Database First Overview<\/a><br><strong>PART 2.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/start-a-new-asp-net-web-application-net-framework-project.php\">Start a New ASP.NET MVC Project<\/a><br><strong>PART 3.<\/strong>Create New Database and Table for EF<br><strong>PART 4.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/install-entity-framework-and-create-entity-data-model.php\">Install Entity Framework and Create Entity Data Model<\/a><br><strong>PART 5.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/mvc-5-crud-operation-using-entity-framework-6.php\">CRUD Operation using Entity Framework 6<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 1:<\/h3>\n\n\n\n<p><strong>Create Database LibraryDB<\/strong>.&nbsp;<strong>Open Server Explorer<\/strong>&nbsp;in Visual Studio. Go to&nbsp;<strong>View<\/strong>&nbsp;&gt;&nbsp;<strong>Server Explorer<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-2.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-2.png\" alt=\"Create Database for EF\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 2:<\/h3>\n\n\n\n<p>Right Click on&nbsp;<strong>Data Connections<\/strong>&nbsp;and click on&nbsp;<strong>Create New SQL Server Database<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-3.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-3.png\" alt=\"Create Database for EF\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 3:<\/h3>\n\n\n\n<p>Give&nbsp;<strong>Server Name<\/strong>&nbsp;as follows and Create Database&nbsp;<strong><code>LibraryDB<\/code><\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-4.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-4.png\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 4:<\/h3>\n\n\n\n<p>Add a New Table&nbsp;<strong>BookDetails<\/strong>&nbsp;in the database. Expand&nbsp;<strong>LibraryDB<\/strong>&nbsp;in server explorer and right click on Tables and click on&nbsp;<strong>Add New Tables<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-5.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-5.png\" alt=\"Create Database for EF\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 5:<\/h3>\n\n\n\n<p>Create a table as mentioned in picture. After designing table click on&nbsp;<strong>Update<\/strong>&nbsp;button to save it into the database.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-6.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-6.png\" alt=\"Create Database for EF\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 6: SQL SCRIPT<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE &#91;dbo].&#91;BookDetails]\r\n(\r\n    &#91;Id] INT NOT NULL PRIMARY KEY IDENTITY, \r\n    &#91;BookName] NVARCHAR(50) NULL, \r\n    &#91;Price] NVARCHAR(50) NULL, \r\n    &#91;Category] NVARCHAR(50) NULL, \r\n    &#91;AuthorName] NVARCHAR(50) NULL, \r\n    &#91;Edition] NVARCHAR(50) NULL, \r\n    &#91;BookCondition] NVARCHAR(50) NULL, \r\n    &#91;Available] NCHAR(10) NULL\r\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SUMMARY:<\/h3>\n\n\n\n<p>In this chapter, you created SQL Database and a Table. In the next chapter, we will\u00a0<strong>Install Entity Framework and Create Data Model.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">IV. Install Entity Framework And Create Entity Data Model<\/h2>\n\n\n\n<p>There are 5 parts in this project and this is 4th Part.<\/p>\n\n\n\n<p>PART 4:<\/p>\n\n\n\n<p><strong>PART 1.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/ef-new-database-first-tutorial-with-asp-net-5-for-beginners.php\">EF \u2013 New Database First Overview<\/a><br><strong>PART 2.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/start-a-new-asp-net-web-application-net-framework-project.php\">Start a New ASP.NET MVC Project<\/a><br><strong>PART 3.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/create-new-database-and-table-for-entity-framework.php\">Create New Database and Table for EF<\/a><br><strong>PART 4.<\/strong>Install Entity Framework and Create Entity Data Model<br><strong>PART 5.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/mvc-5-crud-operation-using-entity-framework-6.php\">CRUD Operation using Entity Framework 6<\/a><br><\/p>\n\n\n\n<p>If you haven&#8217;t install Entity Framework yet, then you can install easily. Just read the following installing guide.<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;<strong>Right click<\/strong>&nbsp;on&nbsp;<strong>Project Name<\/strong>&nbsp;in Solution Explorer and Click&nbsp;<strong>Manage NuGet Packages\u2026<\/strong><br><strong>2.<\/strong>&nbsp;<strong>NuGet Package Manager<\/strong>&nbsp;Window will be open. Here, Browse for&nbsp;<strong>Entity Framework<\/strong>. Now, Click&nbsp;<strong>Install Icon<\/strong>&nbsp;or&nbsp;<strong>Install button<\/strong>&nbsp;to Installing it into your project.<br><strong>3.<\/strong>&nbsp;A&nbsp;<strong>Review Changes<\/strong>&nbsp;Dialog box will appear. Click&nbsp;<strong>OK<\/strong>.<br><strong>4.<\/strong>&nbsp;<strong>Accept License Agreement<\/strong>&nbsp;by clicking on&nbsp;<strong>I Accept<\/strong>&nbsp;button.<br><strong>5.<\/strong>&nbsp;Now, you can see&nbsp;<strong>Entity Framework<\/strong>&nbsp;under&nbsp;<strong>References<\/strong>&nbsp;in&nbsp;<strong>Solution Explorer<\/strong>.<\/p>\n\n\n\n<p>Here, is a Step by Step Pictorial Guide of Installing Entity Framework 6.&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/installing-entity-framework-6-into-your-project.php\">Install Entity Framework 6 Pictorial Guide<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CREATE ENTITY DATA MODEL<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 1:<\/h3>\n\n\n\n<p><strong>Right Click<\/strong>&nbsp;on&nbsp;<strong>Model<\/strong>&nbsp;Folder in&nbsp;<strong>Solution Explorer<\/strong>&nbsp;and click&nbsp;<strong>Add<\/strong>&nbsp;&gt;&nbsp;<strong>New Item<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-7.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-7.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 2:<\/h3>\n\n\n\n<p>Select&nbsp;<strong>Data<\/strong>&nbsp;in&nbsp;<strong>Left Pane<\/strong>&nbsp;and then choose&nbsp;<strong>ADO.NET Entity Data Model<\/strong>&nbsp;in the&nbsp;<strong>middle pane<\/strong>. Give the name to&nbsp;<code>BookDataModel<\/code>&nbsp;and click&nbsp;<strong>Add<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-8.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-8.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 3:<\/h3>\n\n\n\n<p><strong>Entity Data Model Wizard<\/strong>&nbsp;will appear that will ask you to choose your data model. Choose&nbsp;<strong>EF Designer from Database<\/strong>&nbsp;and click&nbsp;<strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-9.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-9.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 4:<\/h3>\n\n\n\n<p>In the next wizard choose the connection properties for your connection string. Just&nbsp;<strong>check the radio button<\/strong>&nbsp;saying&nbsp;<strong>&#8220;Yes, include the sensitive data in the connection string.&#8221;<\/strong>&nbsp;And make sure the&nbsp;<strong>check box is checked<\/strong>&nbsp;which asked you to&nbsp;<strong>&#8220;Save connection setting in Web.Config as:&#8221;<\/strong>&nbsp;and click&nbsp;<strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-10.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-10.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 4:<\/h3>\n\n\n\n<p>Select&nbsp;<strong>Entity Framework 6.x<\/strong>&nbsp;if Wizard asks you to choose&nbsp;<strong>Entity Framework<\/strong>&nbsp;version and click&nbsp;<strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-11.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-11.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 5:<\/h3>\n\n\n\n<p>In the next Windows select object of the database. You must select your table&nbsp;<code>BookDetails<\/code>&nbsp;and click&nbsp;<strong>Finish<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-12.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-12.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 6:<\/h3>\n\n\n\n<p>If everything goes fine then you will see your&nbsp;<code>BookDataModel<\/code>&nbsp;in designer mode.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-13.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-13.png\" alt=\"Create Entity Data Model\"\/><\/a><\/figure>\n\n\n\n<p><strong>Congratulations!<\/strong>&nbsp;You have successfully created entity data model from new database. Now you will see that inserting, updating and deleting operation with a table is so much easy with the help of your BookDataModel.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">V. MVC 5 CRUD Operation Using Entity Framework 6<\/h2>\n\n\n\n<p>Till now, you have completed all the previous chapters. This is the time to combine all the work together and display output in a web browser. You are using Entity Framework so, you don&#8217;t need to worry about writing SQL queries and connection for database operation. All database part will be handled by EF automatically.<\/p>\n\n\n\n<p>There are 5 parts in this project and this is 5th Part.<\/p>\n\n\n\n<p>PART 5:<\/p>\n\n\n\n<p><strong>PART 1.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/ef-new-database-first-tutorial-with-asp-net-5-for-beginners.php\">EF \u2013 New Database First Overview<\/a><br><strong>PART 2.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/start-a-new-asp-net-web-application-net-framework-project.php\">Start a New ASP.NET MVC Project<\/a><br><strong>PART 3.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/create-new-database-and-table-for-entity-framework.php\">Create New Database and Table for EF<\/a><br><strong>PART 4.<\/strong>&nbsp;<a href=\"https:\/\/www.completecsharptutorial.com\/entity-framework-6\/install-entity-framework-and-create-entity-data-model.php\">Install Entity Framework and Create Entity Data Model<\/a><br><strong>PART 5.<\/strong>CRUD Operation using Entity Framework 6<br><\/p>\n\n\n\n<p>Add a new Scaffolding Item to Controller<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 1:<\/h3>\n\n\n\n<p><strong>Right click<\/strong>&nbsp;on Controller folder. Select&nbsp;<strong>Add &gt; New Scaffolded Item.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-14.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-14.png\" alt=\"MVC 5 with Entity Framework 6\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 2:<\/h3>\n\n\n\n<p>A window will open. Select&nbsp;<strong>MVC5 Controller with views, using Entity Framework<\/strong>&nbsp;and click on&nbsp;<strong>Add<\/strong>&nbsp;button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-15.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-15.png\" alt=\"MVC 5 with Entity Framework 6\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 3:<\/h3>\n\n\n\n<p>An&nbsp;<strong>Add Controller<\/strong>&nbsp;window will open. In&nbsp;<strong>Model class<\/strong>, select&nbsp;<code>BookDetails (FirstEFProject.Models)<\/code>&nbsp;and in the&nbsp;<strong>Data context<\/strong>&nbsp;class, select&nbsp;<code>LibraryDBEntities (FirstEFProject.Models)<\/code>&nbsp;and click on&nbsp;<code>ADD<\/code>&nbsp;button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-16.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-16.png\" alt=\"MVC 5 with Entity Framework 6\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 4:<\/h3>\n\n\n\n<p>Now, see the&nbsp;<strong>Solution Explorer<\/strong>. You will notice that a&nbsp;<code>BookDetailsController.cs<\/code>&nbsp;is automatically added. You will also notice that&nbsp;<strong>BookDetails<\/strong>&nbsp;Views is also automatically added.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-17.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-17.png\" alt=\"MVC 5 with Entity Framework 6\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 5:<\/h3>\n\n\n\n<p>Set&nbsp;<code>BookDetailsController<\/code>&nbsp;to start page. Expand&nbsp;<strong>App_Start<\/strong>&nbsp;folder in solution explorer and open&nbsp;<strong><code>RouteConfig.cs<\/code><\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/app_start.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/app_start.png\" alt=\"App_Start Folder\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 6:<\/h3>\n\n\n\n<p>Here change controller name Home to\u00a0<strong>BookDetails<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">defaults: new { controller = \"BookDetails\", action = \"Index\", id = UrlParameter.Optional }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">STEP 7:<\/h3>\n\n\n\n<p>Press&nbsp;<strong>F5<\/strong>&nbsp;to run your project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/Webp.net-gifmaker.gif\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/Webp.net-gifmaker.gif\" alt=\"EF - Database First Output\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">OUTPUT PICTURE<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-18.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-18.png\" alt=\"EF Output 1\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-19.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-19.png\" alt=\"EF Output 2\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-20.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-20.png\" alt=\"EF Output 3\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-21.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-21.png\" alt=\"EF Output 4\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-22.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-22.png\" alt=\"EF Output 5\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-23.png\"><img decoding=\"async\" src=\"https:\/\/www.completecsharptutorial.com\/wp-content\/uploads\/2017\/07\/New-Picture-23.png\" alt=\"EF Output 6\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">SUMMARY:<\/h3>\n\n\n\n<p>Till now, you learned how to\u00a0<strong>create an MVC 5 Project with Entity Framework 6<\/strong>\u00a0with Database First. I hope you won\u2019t get any trouble creating this project. If you have any trouble then you can post your problem in the comment section. In the next chapter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this chapter, we will learn&nbsp;Entity Framework&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189],"tags":[191,576,577],"class_list":["post-4589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","tag-asp-net","tag-entity-framework","tag-mvc"],"_links":{"self":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/4589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/comments?post=4589"}],"version-history":[{"count":2,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/4589\/revisions"}],"predecessor-version":[{"id":4593,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/4589\/revisions\/4593"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media\/4590"}],"wp:attachment":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media?parent=4589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/categories?post=4589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/tags?post=4589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}