public SimpleMembershipInitializer()
            {
                Database.SetInitializer<UserDbContext>(null);

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

                    security.InitializeDatabaseConnection("DefaultConnection", "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);
                }
            }
Esempio n. 2
0
 public void TestInitialize()
 {
     DatabaseMigrations.DeleteAndUpgradeDatabase(this.TestContext);
     this._fixture = FixtureFactory.CreateFixture();
     this._securityMock = this._fixture.CreateAnonymous<Mock<IWebSecurity>>();
     this._security = new WebSecurityWrapper2(this._securityMock.Object);
 }