public SimpleMembershipInitializer() { Database.SetInitializer<TestContext>(null); try { using (var context = new TestContext()) { if (!context.Database.Exists()) { // Create the SimpleMembership database without Entity Framework migration schema ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } WebSecurity.InitializeDatabaseConnection("TestDataModel", "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); } }
private void GoTest(int index) { ViewBag.Title = Methods.GetTitle(index); TestContext db = new TestContext(); int QuestionsCount = (from q in db.questions where q.parent_test == index select q.id).Count(); ViewBag.QuestionsCount = QuestionsCount; int duration = (from t in db.tests where t.id == index select t.duration).First(); ViewBag.Duration = duration; string TestInfo = (from t in db.tests where t.id == index select t.test_info).First(); ViewBag.TestInfo = TestInfo; }