/
20211211104839_Initial.cs
97 lines (91 loc) · 5.08 KB
/
20211211104839_Initial.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EfCoreTemporalTablePart3.Migrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Entreprise",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nom = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
Adresse = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
ValideAu = table.Column<DateTime>(type: "datetime2", nullable: false)
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "ValideAu")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "ValideDu"),
ValideDu = table.Column<DateTime>(type: "datetime2", nullable: false)
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "ValideAu")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "ValideDu")
},
constraints: table =>
{
table.PrimaryKey("PK_Entreprise", x => x.Id);
})
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalHistoryTableName", "EntrepriseHistorique")
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "ValideAu")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "ValideDu");
migrationBuilder.CreateTable(
name: "Employe",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Prenom = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
Nom = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
EntrepriseId = table.Column<int>(type: "int", nullable: false),
PeriodEnd = table.Column<DateTime>(type: "datetime2", nullable: false)
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart"),
PeriodStart = table.Column<DateTime>(type: "datetime2", nullable: false)
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart")
},
constraints: table =>
{
table.PrimaryKey("PK_Employe", x => x.Id);
table.ForeignKey(
name: "FK_Employe_Entreprise",
column: x => x.EntrepriseId,
principalTable: "Entreprise",
principalColumn: "Id");
})
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalHistoryTableName", "EmployeHistory")
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart");
migrationBuilder.CreateIndex(
name: "IX_Employe_EntrepriseId",
table: "Employe",
column: "EntrepriseId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Employe")
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalHistoryTableName", "EmployeHistory")
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart");
migrationBuilder.DropTable(
name: "Entreprise")
.Annotation("SqlServer:IsTemporal", true)
.Annotation("SqlServer:TemporalHistoryTableName", "EntrepriseHistorique")
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
.Annotation("SqlServer:TemporalPeriodEndColumnName", "ValideAu")
.Annotation("SqlServer:TemporalPeriodStartColumnName", "ValideDu");
}
}
}