官术网_书友最值得收藏!

Blog entity script

We will create a Blog table, then alter it to add a primary key constraint, and finally, insert some dummy data into the table. The complete script is available in the GitHub repository at https://github.com/PacktPublishing/Mastering-Entity-Framework-Core/blob/master/Chapter%202/Final/MasteringEFCore.DatabaseFirst.Final/dbo.Blog.sql.

The script required for creating the Blog table and inserting the data is displayed as follows:

    // Code removed for brevity
CREATE TABLE [dbo].[Blog] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Url] NVARCHAR (MAX) NULL
);
GO
// Code removed for brevity
INSERT INTO [Blog] (Url) VALUES
('http://blogs.packtpub.com/dotnet'),
('http://blogs.packtpub.com/dotnetcore'),
('http://blogs.packtpub.com/signalr')
GO

We have looked at the Blog table SQL script, now let's look at the Post table script that will introduce a non-clustered index and foreign key.

主站蜘蛛池模板: 新丰县| 合肥市| 萍乡市| 庐江县| 怀安县| 沙雅县| 巴里| 桑植县| 循化| 淮安市| 剑河县| 镇宁| 当涂县| 汉川市| 射洪县| 凤翔县| 平定县| 庆元县| 桓台县| 都昌县| 海阳市| 张掖市| 福安市| 双牌县| 汶上县| 平邑县| 新民市| 安新县| 乌恰县| 镇坪县| 贡觉县| 黄冈市| 庆元县| 搜索| 阿克| 浪卡子县| 营山县| 喀什市| 蓝山县| 东宁县| 保德县|