Fleshed out entity classes and created command to create student
This commit is contained in:
@@ -19,12 +19,13 @@ namespace BrightGlimmer.Data
|
||||
// dotnet ef migrations update --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasMany(x => x.Phones);
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasOne(x => x.Address);
|
||||
modelBuilder.Entity<Student>()
|
||||
.HasMany(x => x.AssignedCourses);
|
||||
modelBuilder.Entity<Student>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.StudentNumber).IsUnique();
|
||||
entity.HasOne(e => e.Address);
|
||||
entity.HasMany(e => e.Phones);
|
||||
entity.HasMany(e => e.AssignedCourses);
|
||||
});
|
||||
modelBuilder.Entity<AssignedCourse>()
|
||||
.HasOne(x => x.Course);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace BrightGlimmer.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(BgContext))]
|
||||
[Migration("20190424174147_CreateDatabase")]
|
||||
[Migration("20190424233105_CreateDatabase")]
|
||||
partial class CreateDatabase
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -157,6 +157,9 @@ namespace BrightGlimmer.Data.Migrations
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.HasIndex("StudentNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
@@ -147,6 +147,12 @@ namespace BrightGlimmer.Data.Migrations
|
||||
name: "IX_Students_AddressId",
|
||||
table: "Students",
|
||||
column: "AddressId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Students_StudentNumber",
|
||||
table: "Students",
|
||||
column: "StudentNumber",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
@@ -155,6 +155,9 @@ namespace BrightGlimmer.Data.Migrations
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.HasIndex("StudentNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user