Repro:
Create basic application with the model shown below
PM> Install-package entityframework -pre -version 20410
PM> Enable-Migrations
Add custom factory to migrations configuration file as shown below the model
Run the application
Note: EntityException is thrown with the message: "The underlying provider failed on Open."
This message should either be updated to be more informative or this issue should be rectified and the migrations table created in the initializer.
Model:
public class EntityContext : DbContext
{
public DbSet<Entity> Entities { get; set; }
}
public class Entity
{
public int ID { get; set; }
public string Title { get; set; }
public DateTime Timestamp { get; set; }
}
public class MyHistoryContext : HistoryContext
{
public MyHistoryContext(DbConnection existingConnection, bool contextOwnsConnection, string defaultSchema)
: base(existingConnection, contextOwnsConnection, defaultSchema)
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<HistoryRow>().ToTable("YourHistory.Table", "schema");
modelBuilder.Entity<HistoryRow>().Property(h => h.MigrationId).HasColumnName("migration_id");
modelBuilder.Entity<HistoryRow>().Property(h => h.ContextKey).HasColumnName("context_key");
modelBuilder.Entity<HistoryRow>().Property(h => h.Model).HasColumnName("metadata");
}
}
Configuration:
public Configuration()
{
AutomaticMigrationsEnabled = false;
HistoryContextFactory = (connection, ownsConnection, schema) =>
new MyHistoryContext(connection, ownsConnection, schema);
}
Create basic application with the model shown below
PM> Install-package entityframework -pre -version 20410
PM> Enable-Migrations
Add custom factory to migrations configuration file as shown below the model
Run the application
Note: EntityException is thrown with the message: "The underlying provider failed on Open."
This message should either be updated to be more informative or this issue should be rectified and the migrations table created in the initializer.
Model:
public class EntityContext : DbContext
{
public DbSet<Entity> Entities { get; set; }
}
public class Entity
{
public int ID { get; set; }
public string Title { get; set; }
public DateTime Timestamp { get; set; }
}
public class MyHistoryContext : HistoryContext
{
public MyHistoryContext(DbConnection existingConnection, bool contextOwnsConnection, string defaultSchema)
: base(existingConnection, contextOwnsConnection, defaultSchema)
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<HistoryRow>().ToTable("YourHistory.Table", "schema");
modelBuilder.Entity<HistoryRow>().Property(h => h.MigrationId).HasColumnName("migration_id");
modelBuilder.Entity<HistoryRow>().Property(h => h.ContextKey).HasColumnName("context_key");
modelBuilder.Entity<HistoryRow>().Property(h => h.Model).HasColumnName("metadata");
}
}
Configuration:
public Configuration()
{
AutomaticMigrationsEnabled = false;
HistoryContextFactory = (connection, ownsConnection, schema) =>
new MyHistoryContext(connection, ownsConnection, schema);
}