public SimpleMembershipInitializer()
            {
                System.Data.Entity.Database.SetInitializer <FreightTechContext>(null);

                try
                {
                    using (var context = new FreightTechContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework
                            // migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    //WebSecurity.InitializeDatabaseConnection
                    //("DefaultConnection",
                    //"UserProfile", "UserId",
                    //"UserName", autoCreateTables: true);
                    WebSecurity.InitializeDatabaseConnection
                        ("FreightTechConnection",
                        "UserProfile", "UserId",
                        "EmailId", 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);
                }
            }
Пример #2
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (context != null)
         {
             context.Dispose();
             context = null;
         }
     }
 }
Пример #3
0
 public HomeController()
 {
     context = new FreightTechContext();
 }