Skip to content

Commit e64f9fd

Browse files
committed
Fixed #16: Developing Step By Step contains the wrong sample code.
1 parent 3388aa6 commit e64f9fd

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

doc/Developing-Step-By-Step-Angular.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,41 +1203,45 @@ <h3>Adding Database Migration</h3>
12031203
<img class="img-thumbnail" alt="Entity Framework Migration" src="images/phonebook-migrations-core-4.png" /></p>
12041204
<p>This will create a new code based migration file to create <strong>PbPhones</strong>
12051205
table:</p>
1206-
<pre lang="cs">
1207-
public partial class Added_Persons_Table : Migration
1206+
<pre lang="cs">public partial class Added_Phone : Migration
12081207
{
12091208
protected override void Up(MigrationBuilder migrationBuilder)
12101209
{
12111210
migrationBuilder.CreateTable(
1212-
name: "PbPersons",
1211+
name: "PbPhones",
12131212
columns: table =&gt; new
12141213
{
1215-
Id = table.Column&lt;int&gt;(nullable: false)
1214+
Id = table.Column&lt;long&gt;(nullable: false)
12161215
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
12171216
CreationTime = table.Column&lt;DateTime&gt;(nullable: false),
12181217
CreatorUserId = table.Column&lt;long&gt;(nullable: true),
1219-
DeleterUserId = table.Column&lt;long&gt;(nullable: true),
1220-
DeletionTime = table.Column&lt;DateTime&gt;(nullable: true),
1221-
EmailAddress = table.Column&lt;string&gt;(maxLength: 255, nullable: true),
1222-
IsDeleted = table.Column&lt;bool&gt;(nullable: false),
1223-
LastModificationTime = table.Column&lt;DateTime&gt;(nullable: true),
1224-
LastModifierUserId = table.Column&lt;long&gt;(nullable: true),
1225-
Name = table.Column&lt;string&gt;(maxLength: 32, nullable: false),
1226-
Surname = table.Column&lt;string&gt;(maxLength: 32, nullable: false)
1218+
Number = table.Column&lt;string&gt;(maxLength: 16, nullable: false),
1219+
PersonId = table.Column&lt;int&gt;(nullable: false),
1220+
Type = table.Column&lt;byte&gt;(nullable: false)
12271221
},
12281222
constraints: table =&gt;
12291223
{
1230-
table.PrimaryKey("PK_PbPersons", x =&gt; x.Id);
1224+
table.PrimaryKey("PK_PbPhones", x =&gt; x.Id);
1225+
table.ForeignKey(
1226+
name: "FK_PbPhones_PbPersons_PersonId",
1227+
column: x =&gt; x.PersonId,
1228+
principalTable: "PbPersons",
1229+
principalColumn: "Id",
1230+
onDelete: ReferentialAction.Cascade);
12311231
});
1232+
1233+
migrationBuilder.CreateIndex(
1234+
name: "IX_PbPhones_PersonId",
1235+
table: "PbPhones",
1236+
column: "PersonId");
12321237
}
12331238

12341239
protected override void Down(MigrationBuilder migrationBuilder)
12351240
{
12361241
migrationBuilder.DropTable(
1237-
name: "PbPersons");
1242+
name: "PbPhones");
12381243
}
1239-
}
1240-
</pre>
1244+
}</pre>
12411245
<p>Before updating database, we can go to database <strong>InitialPeopleCreator</strong>, rename it to <strong>InitialPeopleAndPhoneCreator</strong>
12421246
and add example <strong>phone numbers</strong> for example people (We renamed
12431247
InitialPeopleCreator.cs to InitialPeopleAndPhoneCreator.cs):</p>

0 commit comments

Comments
 (0)