让我们先准备创建一张数据表:
CREATE TABLE [dbo].[User](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NULL,
[age] [int] NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
这是一张很简单的表,只有三个字段id作为主键,自增,然后姓名,年龄
准备工作做好了,然我们开始对通过EF对数据库进行增删改查