本文整理汇总了C#中MigrationBuilder.AddColumn方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.AddColumn方法的具体用法?C# MigrationBuilder.AddColumn怎么用?C# MigrationBuilder.AddColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigrationBuilder
的用法示例。
在下文中一共展示了MigrationBuilder.AddColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Translation_Content_ContentId", table: "Translation");
migrationBuilder.DropPrimaryKey(name: "PK_Content", table: "Content");
migrationBuilder.DropColumn(name: "Id", table: "Content");
migrationBuilder.AddColumn<Guid>(
name: "ContentContentGuid",
table: "Translation",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "ContentGuid",
table: "Content",
nullable: false,
defaultValueSql: "newsequentialid()");
migrationBuilder.AddPrimaryKey(
name: "PK_Content",
table: "Content",
column: "ContentGuid");
migrationBuilder.AddForeignKey(
name: "FK_Translation_Content_ContentContentGuid",
table: "Translation",
column: "ContentContentGuid",
principalTable: "Content",
principalColumn: "ContentGuid",
onDelete: ReferentialAction.Restrict);
}
开发者ID:nettsundere,项目名称:PersonalWebsite,代码行数:26,代码来源:20151128025750_ReplaceGuidWithIdForContentsAndTranslations.cs
示例2: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsOriginal",
table: "Posts",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "SourceLink",
table: "Posts",
nullable: true);
migrationBuilder.Sql(@"Alter view HierarchyPosts as
WITH Cte (Id, Parentpostid, Depth, Rootid) AS
(SELECT Id,
Replytopostid,
0 AS Thelevel,
Id AS Rootid
FROM Posts
WHERE Replytopostid IS NULL
AND Isdeleted = 0
UNION ALL SELECT Pn.Id,
Pn.Replytopostid,
P1.Depth +1,
P1.Rootid
FROM Posts Pn
INNER JOIN Cte AS P1 ON P1.Id = Pn.Replytopostid
WHERE Pn.Isdeleted = 0)
SELECT Cte.Id AS Postid,
ReplyToPostId,
Depth,
ForumId,
LastChangedDate,
PublishDate,
Title,
Body,
IsModified,
U.UserName,
U.Id,
UserId,
RootId,
IsDeleted,
IsImportantReply,
Views,
IsOriginal,
SourceLink,
(SELECT Count(1)
FROM Userreviews Ur
WHERE Ur.Touserid = P.Userid
AND Ur.Votetype = 1
AND Ur.IsDeleted = 0) AS PositiveReviewsScore,
(SELECT Count(1)
FROM Userreviews Ur
WHERE Ur.Touserid = P.Userid
AND Ur.Votetype = 2
AND Ur.IsDeleted = 0) AS NegativeReviewsScore
FROM Cte
INNER JOIN Posts P ON Cte.Id = P.Id
INNER JOIN Users U ON U.Id = P.Userid");
}
示例3: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchItem");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "DeployDateTime",
schema: "kraken",
table: "ReleaseBatch",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeployEnvironmentId",
schema: "kraken",
table: "ReleaseBatch",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeployUserName",
schema: "kraken",
table: "ReleaseBatch",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId",
schema: "kraken",
table: "ReleaseBatchItem",
column: "ReleaseBatchId",
principalSchema: "kraken",
principalTable: "ReleaseBatch",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例4: Up
public override void Up(MigrationBuilder migration)
{
migration.DropForeignKey(name: "FK_Registration_Member_MemberId", table: "Registration");
migration.DropColumn(name: "MemberId", table: "Registration");
migration.DropTable("Member");
migration.AddColumn(
name: "UserId",
table: "Registration",
type: "nvarchar(450)",
nullable: true);
migration.RenameTable(
name: "AspNetUsers",
newName: "Users");
migration.AddColumn(
name: "Name",
table: "Users",
type: "nvarchar(100)",
nullable: true);
migration.AddForeignKey(
name: "FK_Registration_ApplicationUser_UserId",
table: "Registration",
column: "UserId",
referencedTable: "Users",
referencedColumn: "Id");
}
示例5: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Recipe_Category_CategoryId", table: "Recipe");
migrationBuilder.AddColumn<string>(
name: "Content",
table: "Recipe",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "CoockTime",
table: "Recipe",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CreatedAt",
table: "Recipe",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<bool>(
name: "IsFavorite",
table: "Recipe",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "UpdatedAt",
table: "Recipe",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Recipe_Category_CategoryId",
table: "Recipe",
column: "CategoryId",
principalTable: "Category",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例6: Up
public override void Up(MigrationBuilder migration)
{
migration.DropColumn(name: "Logo", table: "Teams");
migration.AddColumn(
name: "CheerleaderImage",
table: "Teams",
type: "nvarchar(max)",
nullable: true);
migration.AddColumn(
name: "CoachImage",
table: "Teams",
type: "nvarchar(max)",
nullable: true);
migration.AddColumn(
name: "DivisionId",
table: "Teams",
type: "int",
nullable: true);
migration.AddColumn(
name: "HeaderImage",
table: "Teams",
type: "nvarchar(max)",
nullable: true);
migration.AddColumn(
name: "LogoImage",
table: "Teams",
type: "nvarchar(max)",
nullable: true);
migration.AddForeignKey(
name: "FK_Team_Division_DivisionId",
table: "Teams",
column: "DivisionId",
referencedTable: "Divisions",
referencedColumn: "DivisionId");
}
示例7: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "LastUpdated",
table: "Projects",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AddColumn<DateTime>(
name: "LastUpdated",
table: "Products",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AlterColumn<DateTime>(
name: "LastUpdated",
table: "WorkItems",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AlterColumn<DateTime>(
name: "LastUpdated",
table: "ProductCategories",
nullable: false,
defaultValueSql: "GetDate()");
}
示例8: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Leaderboard_Game_GameID", table: "Leaderboard");
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AddColumn<string>(
name: "PlayerName",
table: "Leaderboard",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PlayerPoints",
table: "Leaderboard",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_Leaderboard_Game_GameID",
table: "Leaderboard",
column: "GameID",
principalTable: "Game",
principalColumn: "GameID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例9: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_WorldUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_WorldUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_WorldUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AddColumn<string>(
name: "Firstname",
table: "AspNetUsers",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Lastname",
table: "AspNetUsers",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "PhoneNumber",
table: "AspNetUsers",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_WorldUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_WorldUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_WorldUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.RenameColumn(
name: "PhoneNumber",
table: "AspNetUsers",
newName: "Phonenumber");
}
示例10: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Session_Speaker_SpeakerID", table: "Session");
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AddColumn<bool>(
name: "Special",
table: "Timeslot",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "Special",
table: "Session",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Session_Speaker_SpeakerID",
table: "Session",
column: "SpeakerID",
principalTable: "Speaker",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例11: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>("FirstName", "AspNetUsers", nullable: false);
migrationBuilder.AddColumn<string>("LastName", "AspNetUsers", nullable: false);
migrationBuilder.AddColumn<string>("Location", "AspNetUsers", nullable: true);
migrationBuilder.AddColumn<string>("Twitter", "AspNetUsers", nullable: true);
migrationBuilder.AddColumn<int?>("AvatarID", "AspNetUsers", nullable: true);
}
示例12: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "UserReviews",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "UpdateDate",
table: "UserReviews",
nullable: false,
defaultValueSql: "getutcdate()");
migrationBuilder.Sql(@"Alter view HierarchyPosts as
WITH Cte (Id, Parentpostid, Depth, Rootid) AS
(SELECT Id,
Replytopostid,
0 AS Thelevel,
Id AS Rootid
FROM Posts
WHERE Replytopostid IS NULL
AND Isdeleted = 0
UNION ALL SELECT Pn.Id,
Pn.Replytopostid,
P1.Depth +1,
P1.Rootid
FROM Posts Pn
INNER JOIN Cte AS P1 ON P1.Id = Pn.Replytopostid
WHERE Pn.Isdeleted = 0)
SELECT Cte.Id AS Postid,
Replytopostid,
Depth,
Forumid,
Lastchangeddate,
Publishdate,
Title,
Body,
Ismodified,
U.Username,
U.Id,
Userid,
Rootid,
Isdeleted,
Isimportantreply,
(SELECT Count(1)
FROM Userreviews Ur
WHERE Ur.Touserid = P.Userid
AND Ur.Votetype = 1
AND Ur.IsDeleted = 0) AS PositiveReviewsScore,
(SELECT Count(1)
FROM Userreviews Ur
WHERE Ur.Touserid = P.Userid
AND Ur.Votetype = 2
AND Ur.IsDeleted = 0) AS NegativeReviewsScore
FROM Cte
INNER JOIN Posts P ON Cte.Id = P.Id
INNER JOIN Users U ON U.Id = P.Userid");
}
示例13: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AddColumn<int>(
name: "Progress",
table: "ProjectsModel",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "Status",
table: "ProjectsModel",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "createdDate",
table: "ProjectsModel",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例14: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AddColumn<string>(
name: "CompanyName",
table: "Speaker",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SponsorLevel",
table: "Speaker",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "ID",
table: "Announcement",
nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例15: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DescriptionHtml",
table: "Organization",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Summary",
table: "Organization",
nullable: true);
}