Code First Membership Provider before Migration
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.ModelConfiguration.Conventions;
|
||||
using MileageTraker.Web.Models;
|
||||
|
||||
namespace MileageTraker.Web.Context
|
||||
{
|
||||
public class MileageTrakerContext : DbContext
|
||||
{
|
||||
public DbSet<Log> Logs { get; set; }
|
||||
public DbSet<Vehicle> Vehicles { get; set; }
|
||||
public DbSet<City> Cities { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<Role> Roles { get; set; }
|
||||
|
||||
/*
|
||||
* WebSecurity.Register("Demo", "123456", "demo@demo.com", true, "Demo", "Demo");
|
||||
Roles.CreateRole("Admin");
|
||||
Roles.AddUserToRole("Demo", "Admin");
|
||||
*/
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
|
||||
modelBuilder.Entity<Log>()
|
||||
.HasOptional(l => l.VehiclePreviousLog)
|
||||
.WithMany()
|
||||
.HasForeignKey(l => l.VehiclePreviousLogId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user