Entity Framework Model First Approach in MVC

In Model First approach, we need to create entities, relationships, and inheritance hierarchies directly on the design surface of EDMX and then it will generate database from it

Step1:- First we create a project with the name of Model-First-Approach

Step2:-After creating we get our application like below image

Step3:- we click on the right click on model and chose ADO.NET Entity Data Model

Step4:- we specify the name of model here we put RecordModel

Step5:-  After that a new Wizard will popup from that we need to select second option Empty model and click on Finish button

Step6:- For adding Entity just right click inside the Entity Data Model Designer a new dialog will pop up in that fill properties like as show below
Entity name: Add name of table which you want to create
Base type: None
Entity set: nothing to change here
Key Property (Primary key) Property name: ID
Property type: Int32

Step7:- Right click on entity model on Generate Database from Model a new Wizard will popup

Step8:- We make a database connection (connection string) and then click Test Connection to make sure all settings are correct.

Step9:- The Connection String is generated

Step10:-After clicking on Next button new wizard will pop up with name Generate Database Wizard

Step11:- Database script generated and then clicks on right key and execute the script and table is generated

Entity Framework Model First Approach in MVC Entity Framework Model First Approach in MVC Reviewed by NEERAJ SRIVASTAVA on 2:43:00 PM Rating: 5

No comments:

Powered by Blogger.