Before:

[HierarchyRoot]
public class BaseEntity : Entity
{
    [Field, Key]
    public int Id { get; private set; }

    [Field]
    public Status Status { get; set; }
}
[HierarchyRoot]
public class MyEntity : Entity
{
    [Field, Key]
    public int Id { get; private set; }

    [Field(Length = 100)]
    public string Text { get; set; }
    [Field]
    public Status Status { get; set; }
}

[HierarchyRoot]
public class Status : Entity
{
    [Field, Key]
    public int Id { get; private set; }

    [Field(Length = 100)]
    public string Text { get; set; }
}

After (The type Status is removed):

[HierarchyRoot]
public class BaseEntity : Entity
{
    [Field, Key]
    public int Id { get; private set; }
}
[HierarchyRoot]
public class MyEntity : Entity
{
    [Field, Key]
    public int Id { get; private set; }

    [Field(Length = 100)]
    public string Text { get; set; }
}

public class UpHandler : UpgradeHandler
{
    public override bool CanUpgradeFrom(string oldVersion)
    {
        return true;
    }

    protected override void AddUpgradeHints(Xtensive.Collections.ISet<UpgradeHint> hints)
    {

        hints.Add(new RemoveFieldHint(typeof(BaseEntity), "Status"));
        hints.Add(new RemoveFieldHint(typeof(MyEntity), "Status"));

        hints.Add(new RemoveTypeHint("ConsoleApplication1.Status"));

        base.AddUpgradeHints(hints);
    }
}

The exception

Xtensive.Orm.SchemaSynchronizationException was unhandled
  Message=Extracted schema is not equal to the target schema. Details:
Schema comparison result: TargetIsSubset
Has unsafe actions: true
Has column type changes: false 
Compatible in ValidateLegacy mode: unknown

Unsafe actions:
  RemoveNode, Path=Tables/BaseEntity/Columns/Status_Id
  RemoveNode, Path=Tables/MyEntity/Columns/Status_Id
Schema hints:
  Delete from 'Tables/Status' where ()
Schema difference:
  "./" != "./" (NodeDifference): Unknown
    +Tables: "./Tables (6)" != "./Tables (5)" (NodeCollectionDifference): 3 change(s)
      "./Tables/Status" != "" (NodeDifference): Removed RemoveOnCleanup DataChanged
        +Columns: "./Tables/Status/Columns (2)" != "" (NodeCollectionDifference): 2 change(s)
          "./Tables/Status/Columns/Id" != "" (NodeDifference): Removed
            +Type: "Type: Int32, Length: null, Native type: Int32" != "" (ValueDifference): values differ
          "./Tables/Status/Columns/Text" != "" (NodeDifference): Removed
            +Type: "Type: String?, Length: 100, Native type: VarChar(100)" != "" (ValueDifference): values differ
        +PrimaryIndex: "./Tables/Status/PrimaryIndex (PK_Status)" != "" (NodeDifference): Removed
          +IsUnique: "True" != "False" (ValueDifference): values differ
          +KeyColumns: "./Tables/Status/PrimaryIndex/KeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
            "./Tables/Status/PrimaryIndex/KeyColumns/0" != "" (NodeDifference): Removed
              +Direction: "Positive" != "None" (ValueDifference): values differ
              +Value: "./Tables/Status/Columns/Id" != "" (ValueDifference): values differ
      "./Tables/BaseEntity" != "./Tables/BaseEntity" (NodeDifference): Unknown
        +Columns: "./Tables/BaseEntity/Columns (2)" != "./Tables/BaseEntity/Columns (1)" (NodeCollectionDifference): 1 change(s)
          "./Tables/BaseEntity/Columns/Status_Id" != "" (NodeDifference): Removed
            +Type: "Type: Int32?, Length: null, Native type: Int32" != "" (ValueDifference): values differ
        +SecondaryIndexes: "./Tables/BaseEntity/SecondaryIndexes (1)" != "./Tables/BaseEntity/SecondaryIndexes (0)" (NodeCollectionDifference): 1 change(s)
          "./Tables/BaseEntity/SecondaryIndexes/BaseEntity_FK_Status" != "" (NodeDifference): Removed
            +KeyColumns: "./Tables/BaseEntity/SecondaryIndexes/BaseEntity_FK_Status/KeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/BaseEntity/SecondaryIndexes/BaseEntity_FK_Status/KeyColumns/0" != "" (NodeDifference): Removed
                +Direction: "Positive" != "None" (ValueDifference): values differ
                +Value: "./Tables/BaseEntity/Columns/Status_Id" != "" (ValueDifference): values differ
            +PrimaryKeyColumns: "./Tables/BaseEntity/SecondaryIndexes/BaseEntity_FK_Status/PrimaryKeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/BaseEntity/SecondaryIndexes/BaseEntity_FK_Status/PrimaryKeyColumns/0" != "" (NodeDifference): Removed
                +Direction: "Positive" != "None" (ValueDifference): values differ
                +Value: "./Tables/BaseEntity/Columns/Id" != "" (ValueDifference): values differ
        +ForeignKeys: "./Tables/BaseEntity/ForeignKeys (1)" != "./Tables/BaseEntity/ForeignKeys (0)" (NodeCollectionDifference): 1 change(s)
          "./Tables/BaseEntity/ForeignKeys/FK_BaseEntity_Status_Status" != "" (NodeDifference): Removed
            +PrimaryKey: "./Tables/Status/PrimaryIndex (PK_Status)" != "" (ValueDifference): values differ
            +ForeignKeyColumns: "./Tables/BaseEntity/ForeignKeys/FK_BaseEntity_Status_Status/ForeignKeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/BaseEntity/ForeignKeys/FK_BaseEntity_Status_Status/ForeignKeyColumns/0" != "" (NodeDifference): Removed
                +Value: "./Tables/BaseEntity/Columns/Status_Id" != "" (ValueDifference): values differ
      "./Tables/MyEntity" != "./Tables/MyEntity" (NodeDifference): Unknown
        +Columns: "./Tables/MyEntity/Columns (3)" != "./Tables/MyEntity/Columns (2)" (NodeCollectionDifference): 1 change(s)
          "./Tables/MyEntity/Columns/Status_Id" != "" (NodeDifference): Removed
            +Type: "Type: Int32?, Length: null, Native type: Int32" != "" (ValueDifference): values differ
        +SecondaryIndexes: "./Tables/MyEntity/SecondaryIndexes (1)" != "./Tables/MyEntity/SecondaryIndexes (0)" (NodeCollectionDifference): 1 change(s)
          "./Tables/MyEntity/SecondaryIndexes/MyEntity_FK_Status" != "" (NodeDifference): Removed
            +KeyColumns: "./Tables/MyEntity/SecondaryIndexes/MyEntity_FK_Status/KeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/MyEntity/SecondaryIndexes/MyEntity_FK_Status/KeyColumns/0" != "" (NodeDifference): Removed
                +Direction: "Positive" != "None" (ValueDifference): values differ
                +Value: "./Tables/MyEntity/Columns/Status_Id" != "" (ValueDifference): values differ
            +PrimaryKeyColumns: "./Tables/MyEntity/SecondaryIndexes/MyEntity_FK_Status/PrimaryKeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/MyEntity/SecondaryIndexes/MyEntity_FK_Status/PrimaryKeyColumns/0" != "" (NodeDifference): Removed
                +Direction: "Positive" != "None" (ValueDifference): values differ
                +Value: "./Tables/MyEntity/Columns/Id" != "" (ValueDifference): values differ
        +ForeignKeys: "./Tables/MyEntity/ForeignKeys (1)" != "./Tables/MyEntity/ForeignKeys (0)" (NodeCollectionDifference): 1 change(s)
          "./Tables/MyEntity/ForeignKeys/FK_MyEntity_Status_Status" != "" (NodeDifference): Removed
            +PrimaryKey: "./Tables/Status/PrimaryIndex (PK_Status)" != "" (ValueDifference): values differ
            +ForeignKeyColumns: "./Tables/MyEntity/ForeignKeys/FK_MyEntity_Status_Status/ForeignKeyColumns (1)" != "" (NodeCollectionDifference): 1 change(s)
              "./Tables/MyEntity/ForeignKeys/FK_MyEntity_Status_Status/ForeignKeyColumns/0" != "" (NodeDifference): Removed
                +Value: "./Tables/MyEntity/Columns/Status_Id" != "" (ValueDifference): values differ
  Source=Xtensive.Orm
  StackTrace:
       at Xtensive.Orm.Building.Builders.DomainBuilder.SynchronizeSchema(SchemaUpgradeMode schemaUpgradeMode) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Building\Builders\DomainBuilder.cs:line 343
       at Xtensive.Orm.Building.Builders.DomainBuilder.BuildDomain(DomainConfiguration configuration, DomainBuilderConfiguration builderConfiguration) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Building\Builders\DomainBuilder.cs:line 71
       at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.BuildStageDomain(UpgradeStage stage) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Upgrade\UpgradingDomainBuilder.cs:line 82
       at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Upgrade\UpgradingDomainBuilder.cs:line 59
       at Xtensive.Orm.Domain.Build(DomainConfiguration configuration) in c:\Projects\dataobjects.net\Xtensive.Orm\Xtensive.Orm\Orm\Domain.cs:line 281
       at ConsoleApplication1.Program.Main(String[] args) in c:\Projects\Test\ConsoleApplication1\Program.cs:line 43
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

asked Sep 30 '11 at 07:08

xumix's gravatar image

xumix
425737682


One Answer:

Fixed in the new build

answered Oct 05 '11 at 09:09

xumix's gravatar image

xumix
425737682

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA