public static YATDLContext CreateReadOnly() { var context = new YATDLContext(); context.Configuration.AutoDetectChangesEnabled = false; context.Configuration.ProxyCreationEnabled = false; context.Configuration.LazyLoadingEnabled = false; return context; }
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"); } } }