protected override void Dispose(bool disposing) { if (disposing) { _db.Dispose(); } base.Dispose(disposing); }
private static void Main(string[] args) { var connectionString = ConfigurationManager.AppSettings["defaultConnection"]; if (args.Length > 0) { connectionString = args[0]; } // Use ConferenceContext as entry point for dropping and recreating DB using (var context = new ConferenceContext()) { if (context.Database.Exists()) { context.Database.Delete(); } context.Database.Create(); } Database.SetInitializer <EventStoreDbContext>(null); Database.SetInitializer <MessageLogDbContext>(null); Database.SetInitializer <BlobStorageDbContext>(null); Database.SetInitializer <ConferenceRegistrationDbContext>(null); Database.SetInitializer <RegistrationProcessManagerDbContext>(null); Database.SetInitializer <PaymentsDbContext>(null); DbContext[] contexts = { new EventStoreDbContext(connectionString), new MessageLogDbContext(connectionString), new BlobStorageDbContext(connectionString), new PaymentsDbContext(connectionString), new RegistrationProcessManagerDbContext(connectionString), new ConferenceRegistrationDbContext(connectionString) }; foreach (var context in contexts) { var adapter = (IObjectContextAdapter)context; var script = adapter.ObjectContext.CreateDatabaseScript(); context.Database.ExecuteSqlCommand(script); context.Dispose(); } using (var context = new ConferenceRegistrationDbContext(connectionString)) { ConferenceRegistrationDbContextInitializer.CreateIndexes(context); } using (var context = new RegistrationProcessManagerDbContext(connectionString)) { RegistrationProcessManagerDbContextInitializer.CreateIndexes(context); } using (var context = new PaymentsDbContext(connectionString)) { PaymentsReadDbContextInitializer.CreateViews(context); } MessagingDbInitializer.CreateDatabaseObjects(connectionString, "SqlBus"); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _context.Dispose(); } } _disposed = true; }
public virtual void Dispose(bool disposing) { if (this._isDisposed) { return; } if (disposing) { _ctx.Dispose(); } this._isDisposed = true; }
public void Dispose() { _context.Dispose(); }
public void Dispose() { Db.Dispose(); }