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

            MyIdentityAppContext context = new MyIdentityAppContext();

            context.Database.CreateIfNotExists();
            if (context.Roles.FirstOrDefault(i => i.Name == "User") == null)
            {
                context.Roles.Add(new AppRole("User"));
                context.Roles.Add(new AppRole("Administrator"));
                context.SaveChanges();
            }
            context.Dispose();
        }