protected void Application_Start() { AreaRegistration.RegisterAllAreas(); Database.SetInitializer<RealtyContext>(new DropCreateDatabaseIfModelChanges<RealtyContext>()); RealtyContext db = new RealtyContext(); db.Database.Initialize(true); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); }
public SimpleMembershipInitializer() { try { using (var context = new RealtyContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } } catch (Exception ex) { throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex); } }