-
Notifications
You must be signed in to change notification settings - Fork 110
v 3.0 Breaking Changes
Bilal edited this page Oct 15, 2015
·
2 revisions
Yes, This makes it more unique to store and avoid a lot of confusion. It will also help in developing some more upcoming features.
It was simply un-necessary and confusing.
The type of primary key columns of audit tables was int. It has been changed to long considering that number of logs can increase very rapidly.
public override void Up()
{
//drop dependencies
DropIndex("AuditLogDetails", new[] { "AuditLogId" });
DropForeignKey("dbo.AuditLogDetails", "AuditLogId", "dbo.AuditLogs");
DropPrimaryKey("dbo.AuditLogDetails");
DropPrimaryKey("dbo.AuditLogs");
//main changes
RenameColumn("dbo.AuditLogs", "TableName", "TypeFullName");
RenameColumn("dbo.AuditLogDetails", "ColumnName", "PropertyName");
AlterColumn("dbo.AuditLogDetails", "Id", builder => builder.Long(false, true, null));
AlterColumn("dbo.AuditLogs", "AuditLogId", builder => builder.Long(false, true, null));
AlterColumn("dbo.AuditLogDetails", "AuditLogId", builder => builder.Long(false));
//add dependencies again
AddPrimaryKey("dbo.AuditLogDetails", "Id");
AddPrimaryKey("dbo.AuditLogs", "AuditLogId");
AddForeignKey("dbo.AuditLogDetails", "AuditLogId", "dbo.AuditLogs");
CreateIndex("dbo.AuditLogDetails", "AuditLogId");
}
public override void Down()
{
}
To know more about running migrations visit this MSDN article
var migration = new LogDataMigration(db);
using (var transaction = db.Database.BeginTransaction())
{
try
{
migration.MigrateLegacyLogData();
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
}
}