Beispiel #1
0
        public static YATDLContext CreateReadOnly()
        {
            var context = new YATDLContext();
            context.Configuration.AutoDetectChangesEnabled = false;
            context.Configuration.ProxyCreationEnabled = false;
            context.Configuration.LazyLoadingEnabled = false;

            return context;
        }
Beispiel #2
0
        protected void Application_Start()
        {
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DependencyRegistrator.RegisterDependencies();

            using (var m = new YATDLContext())
            {
                if (!m.Database.Exists())
                {
                    m.Database.Initialize(false);
                    Roles.CreateRole("Administrator");
                }

                var adminUsers = Membership.FindUsersByName("admin");
                if (adminUsers == null || adminUsers.Count == 0)
                {
                    Membership.CreateUser("admin", "admin", "*****@*****.**");
                    Roles.AddUserToRole("admin", "Administrator");
                }
            }
        }