public void CheckIfExistsAndCreate() { using (var conn = this.ConnectionFactory().Create()) { conn.Open(); Assert.IsFalse(UsersTable.Exists(conn)); Assert.IsTrue(UsersTable.CreateIfMissing(conn)); Assert.IsTrue(UsersTable.Exists(conn)); Assert.IsFalse(UsersTable.CreateIfMissing(conn)); UsersTable.Drop(conn); Assert.IsFalse(UsersTable.Exists(conn)); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); var connectionSettings = WebConfigurationManager.ConnectionStrings["default"]; // Optional: creates the Users table if it is not already there. using (var connection = DbProviderFactories.GetFactory(connectionSettings.ProviderName).CreateConnection()) { connection.ConnectionString = connectionSettings.ConnectionString; connection.Open(); UsersTable.CreateIfMissing(connection); } }