private static void Seed()
        {
            Roles.CreateRole("User");
            Roles.CreateRole("Administrator");
            Roles.CreateRole("Teacher");
            foreach (Int32 index in Enumerable.Range(1, 10))
            {
                var name = "user" + index + "@olts.com";
                WebSecurity.CreateUserAndAccount(name, name);
                if (index % 3 == 0)
                {
                    Roles.AddUserToRole(name, "Administrator");
                }
                else if (index % 2 == 0)
                {
                    Roles.AddUserToRole(name, "Teacher");
                }
                else
                {
                    Roles.AddUserToRole(name, "User");
                }
            }

            using (var context = new OltsContext())
            {
                foreach (Int32 index in Enumerable.Range(1, 3))
                {
                    var survey = new Survey
                    {
                        Name = "Survey Name" + index,
                        Description = "Survey Description" + index,
                        Owner = context.Users.First(),
                        Questions = new List<Question>
                        {
                            new Question
                            {
                                QuestionType = QuestionType.Checkbox, Text = "Question " + index,
                                OfferedAnswers = new List<OfferedAnswer> { new OfferedAnswer { AnswerText = "1" }, new OfferedAnswer { AnswerText = "2" }, new OfferedAnswer { AnswerText = "3" } }
                            },
                            new Question
                            {
                                QuestionType = QuestionType.Radio, Text = "Question " + index,
                                OfferedAnswers = new List<OfferedAnswer> { new OfferedAnswer { AnswerText = "1" }, new OfferedAnswer { AnswerText = "2" }, new OfferedAnswer { AnswerText = "3" } }
                            },
                            new Question { QuestionType = QuestionType.Textbox, Text = "Question " + index },
                            new Question { QuestionType = QuestionType.Textarea, Text = "Question " + index }
                        }
                    };
                    context.Surveys.Add(survey);
                }
                context.SaveChanges();
            }
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            Database.SetInitializer<OltsContext>(null);
            using (var context = new OltsContext())
            {
                if (!context.Database.Exists())
                {
                    // Create the SimpleMembership database without Entity Framework migration schema
                    ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                }
            }
        }
 public SimpleMembershipInitializer()
 {
     Database.SetInitializer<OltsContext>(null);
     try
     {
         using (var context = new OltsContext())
         {
             if (!context.Database.Exists())
             {
                 ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
             }
         }
         WebSecurity.InitializeDatabaseConnection("Olts", "Users", "Id", "Name", true);
     #if DEBUG
         Seed();
     #endif
     }
     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);
     }
 }
 protected OltsControllerBase()
     : base()
 {
     _context = new OltsContext();
 }