码迷,mamicode.com
首页 > Web开发 > 详细

asp.net Mvc 增删改查

时间:2020-05-17 16:19:33      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:migration   mini   target   cup   控制   idt   ***   use   key   

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下的连接字符串

技术图片

 

 技术图片

创建一个具有读写操作的控制器

技术图片

 

 技术图片

技术图片

技术图片

 

 

asp.net Mvc 增删改查

标签:migration   mini   target   cup   控制   idt   ***   use   key   

原文地址:https://www.cnblogs.com/shijiehaiyang/p/12905395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!