本文整理汇总了C#中MigrationBuilder.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.CreateTable方法的具体用法?C# MigrationBuilder.CreateTable怎么用?C# MigrationBuilder.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigrationBuilder
的用法示例。
在下文中一共展示了MigrationBuilder.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Club",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Club", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Team",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ClubId = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Team", x => x.Id);
table.ForeignKey(
name: "FK_Team_Club_ClubId",
column: x => x.ClubId,
principalTable: "Club",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
示例2: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema("mab");
migrationBuilder.CreateTable(
name: "MicroAggression",
schema: "mab",
columns: table => new
{
Aggression = table.Column<string>(nullable: false),
Aggressiveness = table.Column<int>(nullable: false),
Created = table.Column<DateTime>(nullable: false),
_Alternatives = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MicroAggression", x => x.Aggression);
});
migrationBuilder.CreateTable(
name: "Offense",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Offenses = table.Column<int>(nullable: false),
User = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Offense", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Correction",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Created = table.Column<DateTime>(nullable: false),
MicroAggressionId = table.Column<string>(nullable: true),
OffenseId = table.Column<Guid>(nullable: false),
Tweet = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Correction", x => x.Id);
table.ForeignKey(
name: "FK_Correction_MicroAggression_MicroAggressionId",
column: x => x.MicroAggressionId,
principalSchema: "mab",
principalTable: "MicroAggression",
principalColumn: "Aggression",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Correction_Offense_OffenseId",
column: x => x.OffenseId,
principalSchema: "mab",
principalTable: "Offense",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
}
示例3: Up
public override void Up(MigrationBuilder migration)
{
migration.CreateTable(
name: "Blog",
columns: table => new
{
BlogId = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
Url = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Blog", x => x.BlogId);
});
migration.CreateTable(
name: "Post",
columns: table => new
{
PostId = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
BlogId = table.Column(type: "int", nullable: false),
Content = table.Column(type: "nvarchar(max)", nullable: true),
Title = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Post", x => x.PostId);
table.ForeignKey(
name: "FK_Post_Blog_BlogId",
columns: x => x.BlogId,
referencedTable: "Blog",
referencedColumn: "BlogId");
});
}
示例4: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Manufacturer",
columns: table => new
{
Id = table.Column<int>(isNullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerIdentityStrategy.IdentityColumn),
Name = table.Column<string>(isNullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturer", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Model",
columns: table => new
{
Id = table.Column<int>(isNullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerIdentityStrategy.IdentityColumn),
Name = table.Column<string>(isNullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Model", x => x.Id);
});
}
示例5: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Contacts",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
FirstName = table.Column<string>(nullable: true),
LastName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Contacts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
CustomerName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
}
示例6: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Issue",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Created = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Issue", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Person",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
IssueId = table.Column<int>(nullable: true),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Person", x => x.Id);
table.ForeignKey(
name: "FK_Person_Issue_IssueId",
column: x => x.IssueId,
principalTable: "Issue",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
}
示例7: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Teacher",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Teacher", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Student",
columns: table => new
{
ID = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true),
TeacherID = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Student", x => x.ID);
table.ForeignKey(
name: "FK_Student_Teacher_TeacherID",
column: x => x.TeacherID,
principalTable: "Teacher",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
}
开发者ID:MaxxDelusional,项目名称:EntityFrameworkContainsExample,代码行数:34,代码来源:20160125183440_InitialMigration.cs
示例8: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Game",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Opponent = table.Column<string>(nullable: true),
Order = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Game", x => x.Id);
});
migrationBuilder.CreateTable(
name: "StatLine",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Assists = table.Column<int>(nullable: false),
FGPercentage = table.Column<double>(nullable: false),
FieldGoals = table.Column<int>(nullable: false),
FieldGoalsAttempted = table.Column<int>(nullable: false),
GameNumber = table.Column<int>(nullable: false),
Player = table.Column<string>(nullable: true),
Points = table.Column<int>(nullable: false),
Rebounds = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StatLine", x => x.Id);
});
}
示例9: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CalendarEvent",
columns: table => new
{
Id = table.Column<string>(isNullable: false),
Body = table.Column<string>(isNullable: true),
End = table.Column<DateTime>(isNullable: false),
IsAllDay = table.Column<bool>(isNullable: true),
Location = table.Column<string>(isNullable: true),
Start = table.Column<DateTime>(isNullable: false),
Subject = table.Column<string>(isNullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CalendarEvent", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Emails",
columns: table => new
{
Id = table.Column<string>(isNullable: false),
Body = table.Column<string>(isNullable: true),
DateTimeSent = table.Column<DateTime>(isNullable: false),
From = table.Column<string>(isNullable: true),
Subject = table.Column<string>(isNullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Emails", x => x.Id);
});
}
示例10: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(name: "CorrectedTweets", schema: "mab");
migrationBuilder.CreateTable(
name: "CorrectedTweet",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
CorrectedOn = table.Column<DateTime>(nullable: false),
ScreenName = table.Column<string>(nullable: true),
StatusId = table.Column<ulong>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CorrectedTweet", x => x.Id);
});
migrationBuilder.CreateTable(
name: "OutgoingTweet",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
InReplyToScreenName = table.Column<string>(nullable: true),
InReplyToStatusId = table.Column<ulong>(nullable: false),
Text = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_OutgoingTweet", x => x.Id);
});
}
示例11: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AnswerData",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
AnsweredBy = table.Column<string>(nullable: true),
Content = table.Column<string>(nullable: true),
QuestionId = table.Column<Guid>(nullable: false),
Votes = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AnswerData", x => x.Id);
});
migrationBuilder.CreateTable(
name: "QuestionData",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
AskedByUserName = table.Column<string>(nullable: true),
Content = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_QuestionData", x => x.Id);
});
}
示例12: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Role",
columns: table => new
{
RoleID = table.Column<int>(nullable: false),
Description = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Role", x => x.RoleID);
});
migrationBuilder.CreateTable(
name: "User",
columns: table => new
{
UserID = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
CustomProperty = table.Column<string>(nullable: true),
Email = table.Column<string>(nullable: true),
Password = table.Column<string>(nullable: false),
RoleID = table.Column<int>(nullable: false),
Username = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.UserID);
table.ForeignKey(
name: "FK_User_Role_RoleID",
column: x => x.RoleID,
principalTable: "Role",
principalColumn: "RoleID");
});
}
示例13: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Migrations",
columns: table => new
{
Context = table.Column<string>(nullable: false),
Version = table.Column<string>(nullable: false),
Metadata = table.Column<string>(type: "ntext", nullable: false),
Migration = table.Column<string>(type: "ntext", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Migrations", x => new { x.Context, x.Version });
});
migrationBuilder.CreateTable(
name: "Snapshots",
columns: table => new
{
Context = table.Column<string>(nullable: false),
Version = table.Column<string>(nullable: false),
Snapshot = table.Column<string>(type: "ntext", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Snapshots", x => x.Context);
});
}
示例14: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Level",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Created = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: true),
UserName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Level", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Quest",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
DueBy = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: true),
Reward = table.Column<string>(nullable: true),
Status = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Quest", x => x.Id);
});
}
示例15: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "State",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_State", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Message",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
StateId = table.Column<int>(nullable: false),
Text = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Message", x => x.Id);
table.ForeignKey(
name: "FK_Message_State_StateId",
column: x => x.StateId,
principalTable: "State",
principalColumn: "Id");
});
}