Hello frnds to day I will explain you how to use entity
framework in mvc in this tutorial we will perform crud operation(Create
,Read,Update and Delete) so lets start with this .For this I have table named student ,sql script of my table
are shown below.
Sql Script :
CREATE TABLE [dbo].[Student](
[SID] [int] IDENTITY(1,1) NOT NULL,
[Std_Name] [varchar](50) NULL,
[Std_RollNo] [varchar](50) NULL,
[Std_Address] [varchar](50) NULL,
CONSTRAINT
[PK_Student] PRIMARY KEY
CLUSTERED
(
[SID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS
= ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Go
After Create the table add this table into
visual studio to create entity framework .
Step 1: Create New Project in Visual Studio.
File->New->Project->Select Asp.net mvc
project
Choose Internet Application
Now Create new folder DAL in your website
Right click on DAL folder and select ADO.net
entity data model named it with your database name whatever your database name
Click Next
Choose your Table or select all tables I have
select student table
Now your table entity and its model class is
ready to use
Now create your controller to use this model and classes
I have create controller named it Home
Choose template and model class and data
context class as shown in below click add button name your controller Home
Now our code is ready to use with complete crud
operation.Debug your code press f5
This is very basic article on entity framework
,in further days I will explain more and operation using entity framework.
Keep enjoying
thanks…









0 comments:
Post a Comment