1.创建项目
已经创建好项目了
2.创建数据库
使用这个数据库或者自己创建一个数据库,一个表就好,简单
USE [LearnAdminlte] GO /****** Object: Table [dbo].[__EFMigrationsHistory] Script Date: 2019/7/30 9:28:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[__EFMigrationsHistory]( [MigrationId] [nvarchar](150) NOT NULL, [ProductVersion] [nvarchar](32) NOT NULL, CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY CLUSTERED ( [MigrationId] 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 /****** Object: Table [dbo].[Admin] Script Date: 2019/7/30 9:28:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Admin]( [Id] [nvarchar](36) NOT NULL, [Name] [nvarchar](max) NULL, [Account] [nvarchar](max) NULL, [Password] [nvarchar](max) NULL, [Email] [nvarchar](max) NULL, [CreateTime] [datetime2](7) NOT NULL, CONSTRAINT [PK_Admin] 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] TEXTIMAGE_ON [PRIMARY] GO /****** Object: Table [dbo].[Bolg] Script Date: 2019/7/30 9:28:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Bolg]( [Id] [nvarchar](36) NOT NULL, [Title] [nvarchar](max) NULL, [ReadCount] [int] NOT NULL, [Content] [nvarchar](max) NULL, [Bolg_category_Id] [nvarchar](max) NULL, [CreateTime] [datetime2](7) NOT NULL, [Like] [int] NOT NULL, [Fack] [int] NOT NULL, [AdminId] [nvarchar](max) NULL, CONSTRAINT [PK_Bolg] 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] TEXTIMAGE_ON [PRIMARY] GO /****** Object: Table [dbo].[Categorys] Script Date: 2019/7/30 9:28:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Categorys]( [Id] [nvarchar](36) NOT NULL, [CategotyName] [nvarchar](max) NULL, [AdminId] [nvarchar](max) NULL, CONSTRAINT [PK_Categorys] 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] TEXTIMAGE_ON [PRIMARY] GO /****** Object: Table [dbo].[Person] Script Date: 2019/7/30 9:28:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Person]( [Id] [nvarchar](36) NOT NULL, [Name] [nvarchar](max) NULL, [Age] [int] NOT NULL, [Occupation] [nvarchar](max) NULL, [Birthday] [datetime2](7) NOT NULL, CONSTRAINT [PK_Person] 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] TEXTIMAGE_ON [PRIMARY] GO
3.在MVC程序中创建ADO.NET 实体数据模型
来自数据库的Code first
创建连接字符串
创建好了就可以看到这些东西 Dbcontext Web.config下的连接字符串
创建一个具有读写操作的控制器