In Database First Approach first we create database and then we will create designer and code file using this database.
create database techaltum_ef use techaltum_ef create table student(stu_id int primary key identity(1,1), stu_name varchar(100), age int, course varchar(100))
First of all open the visual studio->new->Website->Empty Website
Now go to add new item and add Ado.net Entity Data Model
Click on add button and you will get following window
In code first we create code file first and then if database not exist then database will be created automatically at runtime using this code.
As we have already database created so we will select Generate from Database. Later on we will discuss on Empty Model and Code first approach.
Now click on Next button and in the following window click on New Connection and you will get following window where add your connection of database and click on ok button.
As you click on ok button you will get the following window
As you can see this window, in which its showing that by which name our connection string will be stored in Web Config file. Later on we can also change this connection string.
Now click on Next button you will get the following window
Now select tables from your database which you want to use in your project. You can also select View and Stored procedure for the use. In my next articles series I will discuss how we can work with Views and Stored Procedure.
As you can see that it has created a namespace techaltum_efModel in which our classes will be added. We can also change the specific name according to our project or can leave it as it is.
Now click on Finish Button you will get your entity framework classes and designer in your solution explorer
As you can see in your solution explorer it will simply added techaltum.edmx. edmx is the extension of entity framework which means Entity Data Model Xml. In my next article first we will discuss about this file.