예제 #1
0
        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));
            }
        }
예제 #2
0
        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);
            }
        }