public void SetupSchemaIfDatabaseUnInitialized() { lock (VerifiedConnectionStrings) { if (VerifiedConnectionStrings.Contains(ConnectionString)) { IdMapper = ConnectionIdMapper[ConnectionString]; return; } using (var transaction = new TransactionScope()) { using (var connection = OpenConnection()) { LegacyEventTable.LogAndThrowIfUsingLegacySchema(connection); var usingLegacySchema = LegacyEventTable.IsUsingLegacySchema(connection); IdMapper = new SqlServerEventStoreEventTypeToIdMapper(ConnectionString, _nameMapper); ConnectionIdMapper[ConnectionString] = IdMapper; if (!usingLegacySchema && !EventTable.Exists(connection)) { EventTypeTable.Create(connection); EventTable.Create(connection); } VerifiedConnectionStrings.Add(ConnectionString); } transaction.Complete(); } } }
public void SetupSchemaIfDatabaseUnInitialized() { lock(VerifiedConnectionStrings) { if(VerifiedConnectionStrings.Contains(ConnectionString)) { IdMapper = ConnectionIdMapper[ConnectionString]; return; } using(var transaction = new TransactionScope()) { using(var connection = OpenConnection()) { LegacyEventTable.LogAndThrowIfUsingLegacySchema(connection); var usingLegacySchema = LegacyEventTable.IsUsingLegacySchema(connection); IdMapper = new SqlServerEventStoreEventTypeToIdMapper(ConnectionString, _nameMapper); ConnectionIdMapper[ConnectionString] = IdMapper; if(!usingLegacySchema && !EventTable.Exists(connection)) { EventTypeTable.Create(connection); EventTable.Create(connection); } VerifiedConnectionStrings.Add(ConnectionString); } transaction.Complete(); } } }