First, I created Model v1 and fill it with some data:

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

    [Field]
    public string Text { get; set; }
}

[HierarchyRoot]
public class A1 : BaseType
{
    [Field]
    public DateTime Date { get; set; }
}

[HierarchyRoot]
public class A2 : BaseType
{
    [Field]
    public int Length { get; set; }
}

Then I move Hierarchy root attribute Up and use ConcreteTable InheritanceSchema:

[HierarchyRoot(InheritanceSchema.ConcreteTable)]
public abstract class BaseType : Entity
{
    [Field,Key]
    public int Id { get; private set; }

    [Field]
    public string Text { get; set; }
}

public class A1 : BaseType
{
    [Field]
    public DateTime Date { get; set; }
}

public class A2 : BaseType
{
    [Field]
    public int Length { get; set; }
}

Expected that my Data will be exist after safely update by PerformSafely.

Full example:

//[HierarchyRoot(InheritanceSchema.ConcreteTable)]
public abstract class BaseType : Entity
{
    [Field,Key]
    public int Id { get; private set; }

    [Field]
    public string Text { get; set; }
}

[HierarchyRoot]
public class A1 : BaseType
{
    [Field]
    public DateTime Date { get; set; }
}

[HierarchyRoot]
public class A2 : BaseType
{
    [Field]
    public int Length { get; set; }
}

class Program
{
    private static void Main(string[] args)
    {

        var conf = new DomainConfiguration("sqlserver://localhost/DO40-Tests");
        conf.UpgradeMode = DomainUpgradeMode.PerformSafely;
        conf.Types.Register(typeof(A1));
        conf.Types.Register(typeof(A2));
        conf.Types.Register(typeof(BaseType));

        using (var d1 = Domain.Build(conf))
        {
            using (var s = d1.OpenSession())
            using (s.Activate())
            {
                using (var t = s.OpenTransaction())
                {
                    var a1 = new A1() { Text = "A1", Date = DateTime.Now };
                    var a2 = new A2() { Text = "A2", Length = 123 };
                    t.Complete();
                }
            }

            using (var s = d1.OpenSession())
            using (s.Activate())
            {
                using (var t = s.OpenTransaction())
                {
                    foreach (var item in Query.All<A1>())
                    {
                        Console.WriteLine(item);
                    }

                    t.Complete();
                }
            }
        }
    }

}

asked Nov 10 '15 at 04:08

pil0t's gravatar image

pil0t
207575763


One Answer:

Hello pil0t

Thank you for the report. The issue was confirmed and I added a task for it.

Updated: This behavior was fixed. All cleanup actions, which are caused by cross-hierarchical type movement, are unsafe now. Such operations should be performed in DomainUpgradeMode.Perform.

answered Nov 10 '15 at 06:21

Alexey%20Kulakov's gravatar image

Alexey Kulakov
77225

edited Jul 12 '16 at 04:35

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