As you seen ,....... how to to connect database using entityframe work.
No my next session how to Insert Update and delete.
1. Create the table , for an example Emp Table
Sql Query:- Emp Table
CREATE TABLE [dbo].[Emp]
(
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Name] VARCHAR(50) NULL,
[Salary] DECIMAL(18, 2) NULL
)
2> Create the Model --> Right Click add new Class and Name EmpModel
Model :- This class is the bridge between Controller and the View
No my next session how to Insert Update and delete.
1. Create the table , for an example Emp Table
Sql Query:- Emp Table
CREATE TABLE [dbo].[Emp]
(
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Name] VARCHAR(50) NULL,
[Salary] DECIMAL(18, 2) NULL
)
2> Create the Model --> Right Click add new Class and Name EmpModel
Model :- This class is the bridge between Controller and the View
[Table("Emp")]----> System.ComponentModel.DataAnnotations namespace included-->[Ctrl+.]
DbContext :- dbcontext is the primary object which interacting with database with using Model.
using System.Data.Entity; [Ctrl+.]
Add DbSet property to the dbcontext class.
Controller: this class perform as a get or post Action , according to client request.
Only Index Action --> just show the exist data in a table.
Index Action:- Display the List in View. View : It is GUI part which show the controll through which perform the action , Request or Post done. After Running in the browser |