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

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.

主站蜘蛛池模板: 延安市| 屏南县| 英德市| 巴中市| 宁德市| 浮山县| 武义县| 张掖市| 微博| 当阳市| 从化市| 图木舒克市| 中方县| 浏阳市| 库车县| 绥化市| 弋阳县| 禄丰县| 兴海县| 孙吴县| 巴塘县| 新营市| 镇雄县| 常宁市| 应城市| 海南省| 资兴市| 南澳县| 平潭县| 天长市| 朝阳市| 屯留县| 大城县| 施甸县| 大悟县| 永清县| 呈贡县| 延津县| 鲁甸县| 沛县| 乡宁县|