Ok I think I understand how this works. Here's what I've done. Maybe this can be an example for other developers:
In AssemblyInfo.cs we changed the Version. You can also use the mentioned AssemblyInfoAttribute like so:
[Assembly: AssemblyInfo("Fortrus.Model", "1.0.0.2")]
but, as also mentioned, when absent the .Net Assembly version will be taken
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xtensive.Orm.Upgrade;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Fortrus.Model")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Contractors")]
[assembly: AssemblyProduct("Fortrus.Model")]
[assembly: AssemblyCopyright("Copyright © Contractors 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1374f51f-1432-479d-81be-c43cd4e104ea")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
I created an UpgradeHandler that can be used for several versions. The only thing you have to remember is to change the version number in the AssemblyInfo.cs on each version that required additional hints and processing after changing the model (f.i. simple changes like adding a new Field don't need extra processing).
Because we are upgrading from several models to 1 the oldVersion in the UpgradeFrom() override is null before that upgrade takes place.
Notice also the 'goto case "1.0.0.2"' needed to cause a fallthrough to the next level of processing (I avoid goto as much as possible but it comes in handy here).
using Fortrus.Model.Entities.Autorisatie;
using Fortrus.Model.Entities.Businessrules;
using Fortrus.Model.Entities.Messaging;
using Fortrus.Model.Entities.Projecten;
using Fortrus.Model.Entities.Reporting;
using System;
using Xtensive.Orm.Upgrade;
namespace Fortrus.Model.Upgrade
{
public class Upgrader : UpgradeHandler
{
private string m_UpgradeFrom;
public override bool CanUpgradeFrom(string oldVersion)
{
m_UpgradeFrom = oldVersion;
return true;
}
protected override void AddUpgradeHints(Xtensive.Collections.ISet<UpgradeHint> hints)
{
switch (m_UpgradeFrom)
{
case null: // Upgrade to 1.0.0.1
hints.Add(new RenameTypeHint("Projecten.Model.Entities.ActiviteitEntity", typeof(ActiviteitEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.BaselineActiviteitEntity", typeof(BaselineActiviteitEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.BaselineEntity", typeof(BaselineEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.BaselineFolderEntity", typeof(BaselineFolderEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.BaselineObjectEntity", typeof(BaselineObjectEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.BestandEntity", typeof(BestandEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.CitMeldingEntity", typeof(CitMeldingEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.CitObjectEntity", typeof(CitObjectEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.FactuurEntity", typeof(FactuurEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.FactuurRegelEntity", typeof(FactuurRegelEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.FolderEntity", typeof(FolderEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.GunningsVoorstelEntity", typeof(GunningsVoorstelEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.GunningsVoorstelRegelEntity", typeof(GunningsVoorstelRegelEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.HistorieEntity", typeof(HistorieEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.HistorieForeignKeyEntity", typeof(HistorieForeignKeyEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.MOSPadActiviteitEntity", typeof(MOSPadActiviteitEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.MOSPadExportEntity", typeof(MOSPadExportEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.NotitieEntity", typeof(NotitieEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.OfferteEntity", typeof(OfferteEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.OfferteRegelEntity", typeof(OfferteRegelEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.OpdrachtEntity", typeof(OpdrachtEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.OpdrachtgeverEntity", typeof(OpdrachtgeverEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.OpdrachtRegelEntity", typeof(OpdrachtRegelEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadActiviteitEntity", typeof(PadActiviteitEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadFolderEntity", typeof(PadFolderEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadObjectEntity", typeof(PadObjectEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadRootEntity", typeof(PadRootEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadStatusEntity", typeof(PadStatusEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadStatusGroupEntity", typeof(PadStatusGroupEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadStatusMomentEntity", typeof(PadStatusMomentEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadStatusPeriodeEntity", typeof(PadStatusPeriodeEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.PadWerkRegelStatusMomentEntity", typeof(PadWerkRegelStatusMomentEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.ProjectEntity", typeof(ProjectEntity)));
hints.Add(new RenameTypeHint("Fortrus.Reporting.Model.Entities.ReportEntity", typeof(ReportEntity)));
hints.Add(new RenameTypeHint("Fortrus.Reporting.Model.Entities.ReportParameterEntity", typeof(ReportParameterEntity)));
hints.Add(new RenameTypeHint("Fortrus.Reporting.Model.Entities.ReportParameterValueEntity", typeof(ReportParameterValueEntity)));
hints.Add(new RenameTypeHint("Fortrus.Reporting.Model.Entities.RepRootEntity", typeof(RepRootEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.UitvoerderEntity", typeof(UitvoerderEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.WerkEntity", typeof(WerkEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.WerkpakketEntity", typeof(WerkpakketEntity)));
hints.Add(new RenameTypeHint("Projecten.Model.Entities.WerkRegelEntity", typeof(WerkRegelEntity)));
hints.Add(new RenameTypeHint("Fortrus.Businessrules.Model.Entities.AssemblyEntity", typeof(AssemblyEntity)));
hints.Add(new RenameTypeHint("Fortrus.Autorisatie.Model.Entities.AutRootEntity", typeof(AutRootEntity)));
hints.Add(new RenameTypeHint("Fortrus.Businessrules.Model.Entities.BreRootEntity", typeof(BreRootEntity)));
hints.Add(new RenameTypeHint("Fortrus.Businessrules.Model.Entities.BusinessruleEntity", typeof(BusinessruleEntity)));
hints.Add(new RenameTypeHint("Fortrus.Businessrules.Model.Entities.GroupEntity", typeof(GroupEntity)));
hints.Add(new RenameTypeHint("Fortrus.Messaging.Model.Entities.MesRootEntity", typeof(MesRootEntity)));
hints.Add(new RenameTypeHint("Fortrus.Messaging.Model.Entities.MessageEntity", typeof(MessageEntity)));
hints.Add(new RenameTypeHint("Fortrus.Autorisatie.Model.Entities.UserEntity", typeof(UserEntity)));
goto case "1.0.0.1";
case "1.0.0.1": // Upgrade to 1.0.0.2
goto case "1.0.0.2";
case "1.0.0.2": // Upgrade to 1.0.0.3
break;
default:
throw new Exception(string.Format("Upgrade from {0} not possible", m_UpgradeFrom));
}
base.AddUpgradeHints(hints);
}
}
}