From 94aeabbd04ba337e9f83c7b167d9534c43e68138 Mon Sep 17 00:00:00 2001 From: Giovani Date: Sat, 4 May 2019 17:39:10 -0500 Subject: [PATCH] comments to startup file --- BrightGlimmer.Api/Startup.cs | 9 +- BrightGlimmer.Data/BgContext.cs | 2 +- ...20190504201523_Update-Database.Designer.cs | 193 ++++++++++++++++++ .../20190504201523_Update-Database.cs | 26 +++ .../Migrations/BgContextModelSnapshot.cs | 2 +- BrightGlimmer.Data/bright_glimmer.db | Bin 73728 -> 73728 bytes 6 files changed, 228 insertions(+), 4 deletions(-) create mode 100644 BrightGlimmer.Data/Migrations/20190504201523_Update-Database.Designer.cs create mode 100644 BrightGlimmer.Data/Migrations/20190504201523_Update-Database.cs diff --git a/BrightGlimmer.Api/Startup.cs b/BrightGlimmer.Api/Startup.cs index 4420952..8a9b504 100644 --- a/BrightGlimmer.Api/Startup.cs +++ b/BrightGlimmer.Api/Startup.cs @@ -1,4 +1,5 @@ -using BrightGlimmer.Data; +using BrightGlimmer.Api.Domain; +using BrightGlimmer.Data; using BrightGlimmer.Data.Interfaces; using BrightGlimmer.Data.Repositories; using BrightGlimmer.Domain; @@ -26,18 +27,22 @@ namespace BrightGlimmer.Api public void ConfigureServices(IServiceCollection services) { services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) + .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => { + // Allow private fields to deserialize options.SerializerSettings.ContractResolver = new PrivateSetterContractResolver(); }); + /* Setup MediatR */ services.AddMediatR(); services.AddMediatR(typeof(Cqrs.Cqrs).Assembly); // Registers handlers in services project + /* Setup Injectable Repos */ services.AddTransient(typeof(IQueryRepository<>), typeof(QueryRepository<>)); services.AddTransient(typeof(ICommandRepository<>), typeof(CommandRepository<>)); + /* Configure EF Core DbContext */ services.AddDbContext(options => options.UseLazyLoadingProxies() .UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); services.AddTransient(); diff --git a/BrightGlimmer.Data/BgContext.cs b/BrightGlimmer.Data/BgContext.cs index 077d7d7..a5a6b60 100644 --- a/BrightGlimmer.Data/BgContext.cs +++ b/BrightGlimmer.Data/BgContext.cs @@ -17,7 +17,7 @@ namespace BrightGlimmer.Data // dotnet ef migrations add NAME --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api - // dotnet ef migrations update --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api + // dotnet ef database update --project ./BrightGlimmer.Data --startup-project ./BrightGlimmer.Api protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => diff --git a/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.Designer.cs b/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.Designer.cs new file mode 100644 index 0000000..ad6b8f7 --- /dev/null +++ b/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.Designer.cs @@ -0,0 +1,193 @@ +// +using System; +using BrightGlimmer.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace BrightGlimmer.Data.Migrations +{ + [DbContext(typeof(BgContext))] + [Migration("20190504201523_Update-Database")] + partial class UpdateDatabase + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.4-servicing-10062"); + + modelBuilder.Entity("BrightGlimmer.Domain.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("City"); + + b.Property("County"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("Latitude"); + + b.Property("Longitude"); + + b.Property("ModifiedDate"); + + b.Property("StateCode"); + + b.Property("StreetAddress1"); + + b.Property("StreetAddress2"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CourseId"); + + b.Property("CreatedDate"); + + b.Property("Grade"); + + b.Property("IsActive"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("StudentId"); + + b.Property("Term"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("StudentId"); + + b.ToTable("AssignedCourses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Code"); + + b.Property("CreatedDate"); + + b.Property("Description"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Phone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AreaCode"); + + b.Property("CreatedDate"); + + b.Property("IsDeleted"); + + b.Property("ModifiedDate"); + + b.Property("Number"); + + b.Property("StudentId"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.ToTable("Phones"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddressId"); + + b.Property("CreatedDate"); + + b.Property("Email"); + + b.Property("FirstName"); + + b.Property("IsDeleted"); + + b.Property("LastName"); + + b.Property("MiddleName"); + + b.Property("ModifiedDate"); + + b.Property("ProfilePictureUrl"); + + b.Property("StudentNumber"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("StudentNumber") + .IsUnique(); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.AssignedCourse", b => + { + b.HasOne("BrightGlimmer.Domain.Course", "Course") + .WithMany() + .HasForeignKey("CourseId"); + + b.HasOne("BrightGlimmer.Domain.Student", "Student") + .WithMany("AssignedCourses") + .HasForeignKey("StudentId"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Phone", b => + { + b.HasOne("BrightGlimmer.Domain.Student") + .WithMany("Phones") + .HasForeignKey("StudentId"); + }); + + modelBuilder.Entity("BrightGlimmer.Domain.Student", b => + { + b.HasOne("BrightGlimmer.Domain.Address", "Address") + .WithMany() + .HasForeignKey("AddressId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.cs b/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.cs new file mode 100644 index 0000000..be7a9e1 --- /dev/null +++ b/BrightGlimmer.Data/Migrations/20190504201523_Update-Database.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace BrightGlimmer.Data.Migrations +{ + public partial class UpdateDatabase : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Grade", + table: "AssignedCourses", + nullable: true, + oldClrType: typeof(decimal)); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Grade", + table: "AssignedCourses", + nullable: false, + oldClrType: typeof(decimal), + oldNullable: true); + } + } +} diff --git a/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs b/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs index aa5ed36..ba1041a 100644 --- a/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs +++ b/BrightGlimmer.Data/Migrations/BgContextModelSnapshot.cs @@ -57,7 +57,7 @@ namespace BrightGlimmer.Data.Migrations b.Property("CreatedDate"); - b.Property("Grade"); + b.Property("Grade"); b.Property("IsActive"); diff --git a/BrightGlimmer.Data/bright_glimmer.db b/BrightGlimmer.Data/bright_glimmer.db index 49dd8f9ef9788e2791abdba32a80dc43d19c51c2..32909bfcdc43183fcfd1342a9b49de5043780676 100644 GIT binary patch delta 55 qcmZoTz|wGlWr8##(?l6(My8DkOY|4B1SlZm%`5?biGq=_m8p@HiJ6|Mk%^I+g%NHkV?!fj z69upQjJ)FfJcZyA1w$Zk3soM-O-$cfd=yW=|lZO=OXW3{?yJ~Fm4HrKPTFfcVVH^nVw#(1J&w|i!O zSz=x$%r8ErnZ-f*DMgv-rKwfvMfs^!4kf9@C31Sn`MKzh#O4unhe16ulYxIG&?Ei) z^{I@UAb)T&vFJQ7*Xm85o9;d9-h_y{&mqxhE``RJfvK^nF)k?!3q$7T4DE|7(CtOI z4H();V6(iz6@F1rkfYnqwVBc2zx*Tz7GSu;BS#LT61Uml2n4Ia9yUK1_