Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            var c = new ContactListContext();

            #if DEBUG
            Database.SetInitializer <ContactListContext>(
                new MigrateDatabaseToLatestVersion <ContactListContext, Configuration>());
            c.Database.Initialize(true);
            #endif
            //SimpleMembershipInitializer memship = new SimpleMembershipInitializer();
        }
Esempio n. 2
0
 public SimpleMembershipInitializer()
 {
     Database.SetInitializer <ContactListContext>(null);
     try
     {
         using (var context = new ContactListContext())
         {
             if (!context.Database.Exists())
             {
                 // Create the SimpleMembership database without Entity Framework migration schema
                 ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
             }
         }
         WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
     }
     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);
     }
 }