Beispiel #1
0
        public static void AssemblyInitialize(TestContext context)
        {
            DropDatabaseIfExists();
            CreateDatabase();

            using (var dataContext = new OpenAccessContext())
            {
                var schemaHandler = dataContext.GetSchemaHandler();
                schemaHandler.CreateDatabase();
                schemaHandler.ForceExecuteDDLScript(schemaHandler.CreateDDLScript());
            }
        }
        public static void CreateOrUpdateDatabase(this OpenAccessContext context)
        {
            var schemaHandler = context.GetSchemaHandler();

            string script = null;

            if (schemaHandler.DatabaseExists())
            {
                script = schemaHandler.CreateUpdateDDLScript(null);
            }
            else
            {
                schemaHandler.CreateDatabase();
                script = schemaHandler.CreateDDLScript();
            }

            if (!string.IsNullOrEmpty(script))
            {
                schemaHandler.ExecuteDDLScript(script);
            }
        }