This project is read-only.

API Review: Multiple Contexts per Database & Configurable Migrations History Table

The purpose of API Review meetings is to go over new API surface one class/member at a time to ensure we have a consistent and high quality API. We look at how classes are structured, which members are public as well as the names of classes, members and parameters.


Multiple Contexts per Database


  • public string ContextKey

Context key isn't technically correct because we actually use the configuration class name as the key.

Discussed and decided most people think of this as the key for their context so we will leave it as-is.


  • public virtual DbModelBuilder HasDefaultSchema(string schema)

No changes needed.


Migrations History Table Customization


  • public IHistoryContextFactory HistoryContextFactory


  • HistoryContext Create(DbConnection existingConnection, bool contextOwnsConnection, string defaultSchema)

Action Item: We should remove IHistoryContextFactory and just use a Func<HistoryContext>

Opened CodePlex issue:

This will be consistent with what we've done in some other areas


  • public const string TableName
  • public HistoryContext(DbConnection existingConnection, bool contextOwnsConnection, string defaultSchema)
  • protected override void OnModelCreating(DbModelBuilder modelBuilder)
  • public string CacheKey { get; }
  • protected string DefaultSchema { get; }
  • public virtual IDbSet<HistoryRow> History { set; get; }

Action Item: CacheKey should be virtual

  • We discussed making it an explicit implementation of IDbModelCacheKeyProvider but decided there may be scenarios where people need to override it (when their custom OnModelCreating can build a different model for the same provider/default schema pair).

Action Item: We should rename TableName to DefaultTableName to make it clearer


  • public string ContextKey { set; get; }
  • public string MigrationId { set; get; }
  • public byte[] Model { set; get; }
  • public string ProductVersion { set; get; }

Discussed whether this should be HistoryEntry instead. We decided either would be ok and since this has been public for a while we'll just leave it as-is.

Action Item: Need to remove doc comments about this just being public for partial trust (since it's now public to allow config in OnModelCreating etc.)

Last edited Apr 2, 2013 at 11:06 PM by RoMiller, version 3