in program.cs I have
private static bool CheckMigrationVersionAndUpgradeIfNeeded()
{
try
{
using (var db = new jtDbContext())
{
if (db.Database.CompatibleWithModel(false))
{
return true;
}
else
{
return RunMigrations(db);
}
}
}
catch (Exception ex)
{
var s = string.Format("Problem in MigrateIfNeeded /n/p" + ex);
MessageBox.Show(s);
return false;
}
}
private static bool RunMigrations(jtDbContext db)
{
if (!AskForPassword()) { return false}
return db.RunMigrations();
}
in my context i have
public void RunMigrations()
{
var configuration = new Configuration();
var migrator = new DbMigrator(configuration);
var pendings = migrator.GetPendingMigrations();
foreach (var pending in pendings)
{
migrator.Update(pending);
}
}
I see from this question that there was an issue in EF5 relating to this field.
I am using DevExpress Xaf in the project but I cant see how this could be relevant.
I can still run the migration by typing update-database at the PM> prompt
I can work around the problem by running the following script prior to updating
ALTER TABLE dbo.__MigrationHistory ADD CreatedOn DateTime Default GETDATE()
GO
UPDATE dbo.__MigrationHistory SET CreatedOn = GETDATE()
[Update] The problem happens when running within the VS2015 Update1 IDE. It does not happen when I run the .exe