Skip to content

Commit

Permalink
refactor dbcontexts
Browse files Browse the repository at this point in the history
  • Loading branch information
alimon808 committed Nov 2, 2017
1 parent c868b68 commit 7e94203
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
15 changes: 5 additions & 10 deletions ContosoUniversity.Data/DbContexts/ApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ContosoUniversity.Data.Entities;
using Microsoft.EntityFrameworkCore;

namespace ContosoUniversity.Data
namespace ContosoUniversity.Data.DbContexts
{
public class ApplicationContext : DbContext
{
Expand All @@ -25,15 +25,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
schema = null;
}
modelBuilder.Entity<Course>().ToTable("Course", schema);
modelBuilder.Entity<Enrollment>().ToTable("Enrollment", schema);
modelBuilder.Entity<Student>().ToTable("Student", schema);
modelBuilder.Entity<Department>().ToTable("Department", schema);
modelBuilder.Entity<Instructor>().ToTable("Instructor", schema);
modelBuilder.Entity<OfficeAssignment>().ToTable("OfficeAssignment", schema);
modelBuilder.Entity<CourseAssignment>().ToTable("CourseAssignment", schema);
modelBuilder.Entity<Person>().ToTable("Person", schema);
modelBuilder.Entity<CourseAssignment>().HasKey(c => new { c.CourseID, c.InstructorID });

var config = new DbContextConfig();
config.ApplicationContextConfig(modelBuilder, schema);

}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using ContosoUniversity.Data.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
Expand Down
9 changes: 2 additions & 7 deletions ContosoUniversity.Data/DbContexts/SecureApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ protected override void OnModelCreating(ModelBuilder builder)
dbSchema = null;
}

builder.Entity<ApplicationUser>().ToTable("Users", dbSchema);
builder.Entity<IdentityRole>().ToTable("Role", dbSchema);
builder.Entity<IdentityUserClaim<string>>().ToTable("UserClaim", dbSchema);
builder.Entity<IdentityUserRole<string>>().ToTable("UserRole", dbSchema);
builder.Entity<IdentityUserLogin<string>>().ToTable("UserLogin", dbSchema);
builder.Entity<IdentityRoleClaim<string>>().ToTable("RoleClaim", dbSchema);
builder.Entity<IdentityUserToken<string>>().ToTable("UserToken", dbSchema);
var config = new DbContextConfig();
config.SecureApplicationContextConfig(builder, dbSchema);
}
}
}

0 comments on commit 7e94203

Please sign in to comment.