예제 #1
0
        public string Create()
        {
            var schemaExport = new SchemaExport(configuration);

            databaseProvider.CreateIfNotExists();

            var stringBuilder = new StringBuilder();

            schemaExport.Create(x => stringBuilder.Append(x), false);
            var statement = stringBuilder.ToString();

            statement = string.IsNullOrWhiteSpace(statement) ? null : statement;

            if (!databaseProvider.Exists())
            {
                databaseProvider.Create();
                schemaExport.Execute(false, true, false);
            }
            else
            {
                try
                {
                    new SchemaValidator(configuration).Validate();
                }
                catch
                {
                    schemaExport.Execute(false, true, false);
                }
            }

            return(statement);
        }