void InstallSchema() { Console.WriteLine("Performing migration"); var migrator = new DatabaseMigrator(); migrator.Migrate(Store); var output = new StringBuilder(); SchemaGenerator.WriteTableSchema(new CustomerMap(), null, output); var mappings = new DocumentMap[] { new CustomerMap(), new ProductMap(), new LineItemMap() }; Mappings.Install(mappings); using (var transaction = Store.BeginTransaction(IsolationLevel.ReadCommitted)) { output.Clear(); foreach (var map in mappings) { SchemaGenerator.WriteTableSchema(map, null, output); } transaction.ExecuteScalar <int>(output.ToString()); transaction.Commit(); } }
void InstallSchema() { Console.WriteLine("Performing migration"); var migrator = new DatabaseMigrator(); migrator.Migrate(Store); var output = new StringBuilder(); SchemaGenerator.WriteTableSchema(new CustomerMap(), null, output); // needed for products, but not to generate the table Mappings.Install(new List <DocumentMap>() { new ProductMap <Product>() }); // needed to generate the table var mappings = new DocumentMap[] { new OrderMap(), new CustomerMap(), new SpecialProductMap(), new LineItemMap(), new BrandMap(), new MachineMap() }; Mappings.Install(mappings); using (var transaction = Store.BeginTransaction(IsolationLevel.ReadCommitted)) { output.Clear(); foreach (var map in mappings) { SchemaGenerator.WriteTableSchema(map, null, output); } transaction.ExecuteScalar <int>(output.ToString()); transaction.ExecuteScalar <int>($"alter table [{nameof(Customer)}] add [RowVersion] rowversion"); transaction.Commit(); } }