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

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.

主站蜘蛛池模板: 大余县| 廊坊市| 福建省| 霍林郭勒市| 临夏市| 武川县| 汝南县| 清苑县| 尚志市| 罗平县| 鄂伦春自治旗| 仪陇县| 上犹县| 怀来县| 县级市| 北流市| 南昌市| 丹东市| 甘孜| 厦门市| 永丰县| 会宁县| 汽车| 三明市| 小金县| 红桥区| 磴口县| 类乌齐县| 北川| 三台县| 宝丰县| 海阳市| 南澳县| 山西省| 汉源县| 南靖县| 合作市| 长海县| 简阳市| 龙泉市| 抚宁县|