File Migrations/20181126174142_AddVehicleTable.Designer.cs copied from file Migrations/20181113173611_SeedFeatures.Designer.cs (similarity 55%) (mode: 100644) (index 01029bc..09d11be) |
1 |
1 |
// <auto-generated /> |
// <auto-generated /> |
|
2 |
|
using System; |
2 |
3 |
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
3 |
4 |
using Microsoft.EntityFrameworkCore.Infrastructure; |
using Microsoft.EntityFrameworkCore.Infrastructure; |
4 |
5 |
using Microsoft.EntityFrameworkCore.Metadata; |
using Microsoft.EntityFrameworkCore.Metadata; |
|
... |
... |
using vega.Persistence; |
9 |
10 |
namespace vega.Migrations |
namespace vega.Migrations |
10 |
11 |
{ |
{ |
11 |
12 |
[DbContext(typeof(VegaDbContext))] |
[DbContext(typeof(VegaDbContext))] |
12 |
|
[Migration("20181113173611_SeedFeatures")] |
|
13 |
|
partial class SeedFeatures |
|
|
13 |
|
[Migration("20181126174142_AddVehicleTable")] |
|
14 |
|
partial class AddVehicleTable |
14 |
15 |
{ |
{ |
15 |
16 |
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
16 |
17 |
{ |
{ |
|
... |
... |
namespace vega.Migrations |
26 |
27 |
.ValueGeneratedOnAdd() |
.ValueGeneratedOnAdd() |
27 |
28 |
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
28 |
29 |
|
|
29 |
|
b.Property<int>("MyProperty"); |
|
30 |
|
|
|
31 |
30 |
b.Property<string>("Name") |
b.Property<string>("Name") |
32 |
31 |
.IsRequired() |
.IsRequired() |
33 |
32 |
.HasMaxLength(255); |
.HasMaxLength(255); |
|
... |
... |
namespace vega.Migrations |
71 |
70 |
b.ToTable("Models"); |
b.ToTable("Models"); |
72 |
71 |
}); |
}); |
73 |
72 |
|
|
|
73 |
|
modelBuilder.Entity("vega.Models.Vehicle", b => |
|
74 |
|
{ |
|
75 |
|
b.Property<int>("Id") |
|
76 |
|
.ValueGeneratedOnAdd() |
|
77 |
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|
78 |
|
|
|
79 |
|
b.Property<string>("ContactEmail") |
|
80 |
|
.HasMaxLength(255); |
|
81 |
|
|
|
82 |
|
b.Property<string>("ContactName") |
|
83 |
|
.IsRequired() |
|
84 |
|
.HasMaxLength(255); |
|
85 |
|
|
|
86 |
|
b.Property<string>("ContactPhone") |
|
87 |
|
.IsRequired() |
|
88 |
|
.HasMaxLength(255); |
|
89 |
|
|
|
90 |
|
b.Property<bool>("IsRegistered"); |
|
91 |
|
|
|
92 |
|
b.Property<DateTime>("LastUpdate"); |
|
93 |
|
|
|
94 |
|
b.Property<int>("ModelId"); |
|
95 |
|
|
|
96 |
|
b.HasKey("Id"); |
|
97 |
|
|
|
98 |
|
b.HasIndex("ModelId"); |
|
99 |
|
|
|
100 |
|
b.ToTable("Vehicles"); |
|
101 |
|
}); |
|
102 |
|
|
|
103 |
|
modelBuilder.Entity("vega.Models.VehicleFeature", b => |
|
104 |
|
{ |
|
105 |
|
b.Property<int>("VehicleId"); |
|
106 |
|
|
|
107 |
|
b.Property<int>("FeatureId"); |
|
108 |
|
|
|
109 |
|
b.HasKey("VehicleId", "FeatureId"); |
|
110 |
|
|
|
111 |
|
b.HasIndex("FeatureId"); |
|
112 |
|
|
|
113 |
|
b.ToTable("VehicleFeatures"); |
|
114 |
|
}); |
|
115 |
|
|
74 |
116 |
modelBuilder.Entity("vega.Models.Model", b => |
modelBuilder.Entity("vega.Models.Model", b => |
75 |
117 |
{ |
{ |
76 |
118 |
b.HasOne("vega.Models.Make", "Make") |
b.HasOne("vega.Models.Make", "Make") |
|
... |
... |
namespace vega.Migrations |
78 |
120 |
.HasForeignKey("MakeId") |
.HasForeignKey("MakeId") |
79 |
121 |
.OnDelete(DeleteBehavior.Cascade); |
.OnDelete(DeleteBehavior.Cascade); |
80 |
122 |
}); |
}); |
|
123 |
|
|
|
124 |
|
modelBuilder.Entity("vega.Models.Vehicle", b => |
|
125 |
|
{ |
|
126 |
|
b.HasOne("vega.Models.Model", "Model") |
|
127 |
|
.WithMany() |
|
128 |
|
.HasForeignKey("ModelId") |
|
129 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
130 |
|
}); |
|
131 |
|
|
|
132 |
|
modelBuilder.Entity("vega.Models.VehicleFeature", b => |
|
133 |
|
{ |
|
134 |
|
b.HasOne("vega.Models.Feature", "Feature") |
|
135 |
|
.WithMany() |
|
136 |
|
.HasForeignKey("FeatureId") |
|
137 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
138 |
|
|
|
139 |
|
b.HasOne("vega.Models.Vehicle", "Vehicle") |
|
140 |
|
.WithMany("Features") |
|
141 |
|
.HasForeignKey("VehicleId") |
|
142 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
143 |
|
}); |
81 |
144 |
#pragma warning restore 612, 618 |
#pragma warning restore 612, 618 |
82 |
145 |
} |
} |
83 |
146 |
} |
} |
File Migrations/20181126174142_AddVehicleTable.cs added (mode: 100644) (index 0000000..2e046c0) |
|
1 |
|
using System; |
|
2 |
|
using Microsoft.EntityFrameworkCore.Metadata; |
|
3 |
|
using Microsoft.EntityFrameworkCore.Migrations; |
|
4 |
|
|
|
5 |
|
namespace vega.Migrations |
|
6 |
|
{ |
|
7 |
|
public partial class AddVehicleTable : Migration |
|
8 |
|
{ |
|
9 |
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
10 |
|
{ |
|
11 |
|
migrationBuilder.DropColumn( |
|
12 |
|
name: "MyProperty", |
|
13 |
|
table: "Features"); |
|
14 |
|
|
|
15 |
|
migrationBuilder.CreateTable( |
|
16 |
|
name: "Vehicles", |
|
17 |
|
columns: table => new |
|
18 |
|
{ |
|
19 |
|
Id = table.Column<int>(nullable: false) |
|
20 |
|
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), |
|
21 |
|
ModelId = table.Column<int>(nullable: false), |
|
22 |
|
IsRegistered = table.Column<bool>(nullable: false), |
|
23 |
|
ContactName = table.Column<string>(maxLength: 255, nullable: false), |
|
24 |
|
ContactPhone = table.Column<string>(maxLength: 255, nullable: false), |
|
25 |
|
ContactEmail = table.Column<string>(maxLength: 255, nullable: true), |
|
26 |
|
LastUpdate = table.Column<DateTime>(nullable: false) |
|
27 |
|
}, |
|
28 |
|
constraints: table => |
|
29 |
|
{ |
|
30 |
|
table.PrimaryKey("PK_Vehicles", x => x.Id); |
|
31 |
|
table.ForeignKey( |
|
32 |
|
name: "FK_Vehicles_Models_ModelId", |
|
33 |
|
column: x => x.ModelId, |
|
34 |
|
principalTable: "Models", |
|
35 |
|
principalColumn: "id", |
|
36 |
|
onDelete: ReferentialAction.Cascade); |
|
37 |
|
}); |
|
38 |
|
|
|
39 |
|
migrationBuilder.CreateTable( |
|
40 |
|
name: "VehicleFeatures", |
|
41 |
|
columns: table => new |
|
42 |
|
{ |
|
43 |
|
VehicleId = table.Column<int>(nullable: false), |
|
44 |
|
FeatureId = table.Column<int>(nullable: false) |
|
45 |
|
}, |
|
46 |
|
constraints: table => |
|
47 |
|
{ |
|
48 |
|
table.PrimaryKey("PK_VehicleFeatures", x => new { x.VehicleId, x.FeatureId }); |
|
49 |
|
table.ForeignKey( |
|
50 |
|
name: "FK_VehicleFeatures_Features_FeatureId", |
|
51 |
|
column: x => x.FeatureId, |
|
52 |
|
principalTable: "Features", |
|
53 |
|
principalColumn: "Id", |
|
54 |
|
onDelete: ReferentialAction.Cascade); |
|
55 |
|
table.ForeignKey( |
|
56 |
|
name: "FK_VehicleFeatures_Vehicles_VehicleId", |
|
57 |
|
column: x => x.VehicleId, |
|
58 |
|
principalTable: "Vehicles", |
|
59 |
|
principalColumn: "Id", |
|
60 |
|
onDelete: ReferentialAction.Cascade); |
|
61 |
|
}); |
|
62 |
|
|
|
63 |
|
migrationBuilder.CreateIndex( |
|
64 |
|
name: "IX_VehicleFeatures_FeatureId", |
|
65 |
|
table: "VehicleFeatures", |
|
66 |
|
column: "FeatureId"); |
|
67 |
|
|
|
68 |
|
migrationBuilder.CreateIndex( |
|
69 |
|
name: "IX_Vehicles_ModelId", |
|
70 |
|
table: "Vehicles", |
|
71 |
|
column: "ModelId"); |
|
72 |
|
} |
|
73 |
|
|
|
74 |
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
75 |
|
{ |
|
76 |
|
migrationBuilder.DropTable( |
|
77 |
|
name: "VehicleFeatures"); |
|
78 |
|
|
|
79 |
|
migrationBuilder.DropTable( |
|
80 |
|
name: "Vehicles"); |
|
81 |
|
|
|
82 |
|
migrationBuilder.AddColumn<int>( |
|
83 |
|
name: "MyProperty", |
|
84 |
|
table: "Features", |
|
85 |
|
nullable: false, |
|
86 |
|
defaultValue: 0); |
|
87 |
|
} |
|
88 |
|
} |
|
89 |
|
} |
File Migrations/VegaDbContextModelSnapshot.cs changed (mode: 100644) (index acfa742..d6e5dd5) |
1 |
1 |
// <auto-generated /> |
// <auto-generated /> |
|
2 |
|
using System; |
2 |
3 |
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
3 |
4 |
using Microsoft.EntityFrameworkCore.Infrastructure; |
using Microsoft.EntityFrameworkCore.Infrastructure; |
4 |
5 |
using Microsoft.EntityFrameworkCore.Metadata; |
using Microsoft.EntityFrameworkCore.Metadata; |
|
... |
... |
namespace vega.Migrations |
24 |
25 |
.ValueGeneratedOnAdd() |
.ValueGeneratedOnAdd() |
25 |
26 |
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
26 |
27 |
|
|
27 |
|
b.Property<int>("MyProperty"); |
|
28 |
|
|
|
29 |
28 |
b.Property<string>("Name") |
b.Property<string>("Name") |
30 |
29 |
.IsRequired() |
.IsRequired() |
31 |
30 |
.HasMaxLength(255); |
.HasMaxLength(255); |
|
... |
... |
namespace vega.Migrations |
69 |
68 |
b.ToTable("Models"); |
b.ToTable("Models"); |
70 |
69 |
}); |
}); |
71 |
70 |
|
|
|
71 |
|
modelBuilder.Entity("vega.Models.Vehicle", b => |
|
72 |
|
{ |
|
73 |
|
b.Property<int>("Id") |
|
74 |
|
.ValueGeneratedOnAdd() |
|
75 |
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|
76 |
|
|
|
77 |
|
b.Property<string>("ContactEmail") |
|
78 |
|
.HasMaxLength(255); |
|
79 |
|
|
|
80 |
|
b.Property<string>("ContactName") |
|
81 |
|
.IsRequired() |
|
82 |
|
.HasMaxLength(255); |
|
83 |
|
|
|
84 |
|
b.Property<string>("ContactPhone") |
|
85 |
|
.IsRequired() |
|
86 |
|
.HasMaxLength(255); |
|
87 |
|
|
|
88 |
|
b.Property<bool>("IsRegistered"); |
|
89 |
|
|
|
90 |
|
b.Property<DateTime>("LastUpdate"); |
|
91 |
|
|
|
92 |
|
b.Property<int>("ModelId"); |
|
93 |
|
|
|
94 |
|
b.HasKey("Id"); |
|
95 |
|
|
|
96 |
|
b.HasIndex("ModelId"); |
|
97 |
|
|
|
98 |
|
b.ToTable("Vehicles"); |
|
99 |
|
}); |
|
100 |
|
|
|
101 |
|
modelBuilder.Entity("vega.Models.VehicleFeature", b => |
|
102 |
|
{ |
|
103 |
|
b.Property<int>("VehicleId"); |
|
104 |
|
|
|
105 |
|
b.Property<int>("FeatureId"); |
|
106 |
|
|
|
107 |
|
b.HasKey("VehicleId", "FeatureId"); |
|
108 |
|
|
|
109 |
|
b.HasIndex("FeatureId"); |
|
110 |
|
|
|
111 |
|
b.ToTable("VehicleFeatures"); |
|
112 |
|
}); |
|
113 |
|
|
72 |
114 |
modelBuilder.Entity("vega.Models.Model", b => |
modelBuilder.Entity("vega.Models.Model", b => |
73 |
115 |
{ |
{ |
74 |
116 |
b.HasOne("vega.Models.Make", "Make") |
b.HasOne("vega.Models.Make", "Make") |
|
... |
... |
namespace vega.Migrations |
76 |
118 |
.HasForeignKey("MakeId") |
.HasForeignKey("MakeId") |
77 |
119 |
.OnDelete(DeleteBehavior.Cascade); |
.OnDelete(DeleteBehavior.Cascade); |
78 |
120 |
}); |
}); |
|
121 |
|
|
|
122 |
|
modelBuilder.Entity("vega.Models.Vehicle", b => |
|
123 |
|
{ |
|
124 |
|
b.HasOne("vega.Models.Model", "Model") |
|
125 |
|
.WithMany() |
|
126 |
|
.HasForeignKey("ModelId") |
|
127 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
128 |
|
}); |
|
129 |
|
|
|
130 |
|
modelBuilder.Entity("vega.Models.VehicleFeature", b => |
|
131 |
|
{ |
|
132 |
|
b.HasOne("vega.Models.Feature", "Feature") |
|
133 |
|
.WithMany() |
|
134 |
|
.HasForeignKey("FeatureId") |
|
135 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
136 |
|
|
|
137 |
|
b.HasOne("vega.Models.Vehicle", "Vehicle") |
|
138 |
|
.WithMany("Features") |
|
139 |
|
.HasForeignKey("VehicleId") |
|
140 |
|
.OnDelete(DeleteBehavior.Cascade); |
|
141 |
|
}); |
79 |
142 |
#pragma warning restore 612, 618 |
#pragma warning restore 612, 618 |
80 |
143 |
} |
} |
81 |
144 |
} |
} |
File Models/Vehicle.cs added (mode: 100644) (index 0000000..05beab4) |
|
1 |
|
using System; |
|
2 |
|
using System.Collections.Generic; |
|
3 |
|
using System.Collections.ObjectModel; |
|
4 |
|
using System.ComponentModel.DataAnnotations; |
|
5 |
|
using System.ComponentModel.DataAnnotations.Schema; |
|
6 |
|
|
|
7 |
|
namespace vega.Models |
|
8 |
|
{ |
|
9 |
|
[Table("Vehicles")] |
|
10 |
|
public class Vehicle |
|
11 |
|
{ |
|
12 |
|
public Vehicle() |
|
13 |
|
{ |
|
14 |
|
Features = new Collection<VehicleFeature>(); |
|
15 |
|
} |
|
16 |
|
public int Id { get; set; } |
|
17 |
|
[Required] |
|
18 |
|
public int ModelId { get; set; } |
|
19 |
|
public Model Model { get; set; } |
|
20 |
|
public bool IsRegistered { get; set; } |
|
21 |
|
public ICollection<VehicleFeature> Features { get; set;} |
|
22 |
|
|
|
23 |
|
[Required] |
|
24 |
|
[StringLength(255)] |
|
25 |
|
public string ContactName { get; set; } |
|
26 |
|
|
|
27 |
|
[Required] |
|
28 |
|
[StringLength(255)] |
|
29 |
|
public string ContactPhone { get; set; } |
|
30 |
|
|
|
31 |
|
[StringLength(255)] |
|
32 |
|
public string ContactEmail { get; set; } public DateTime LastUpdate { get; set; } |
|
33 |
|
} |
|
34 |
|
} |