After update I have lots of my unit tests failed. The problem is that Entity is not persisted and/or initialized after it was created.

For example property EntitySet<t> is null after calling new MyEntity() in 5.0.1 and not null in beta1. The same with Id property. It is set automatically in beta1 and not set in 5.0.1.

It looks like a change in defaults. Where should I look?

UPDATE: some code

[HierarchyRoot]
[KeyGenerator(KeyGeneratorKind.Default, Name = "TaskAssignmentKeyGenerator")]
public class TaskAssignment : Entity
{
    public TaskAssignment(Session session) : base(session) {}

    [Key]
    [Field]
    public int Id { get; set; }

    [Field]
    public Task Task { get; set; }
}
[HierarchyRoot(InheritanceSchema = InheritanceSchema.ClassTable)]
[KeyGenerator(KeyGeneratorKind.Default, Name = "TaskKeyGenerator")]
public class Task : Entity
{
    [Key]
    [Field]
    public int Id { get; set; }

    [Field]
    [Association(PairTo = "Task")]
    public EntitySet<TaskAssignment> TaskAssignments { get; set; }
}

    [Test]
    public void Foo()
    {
        var task = new Task(Session.Current);
        var ta = new TaskAssignment(Session.Current) {Task = task};
        Session.Current.SaveChanges(); // optional, was added just to make sure
        Assert.That(task.TaskAssignments != null); // fails after update to 5.0.1 from beta1
    }

asked Sep 04 '14 at 08:23

Pavel%20Kudinov's gravatar image

Pavel Kudinov
7335

edited Sep 06 '14 at 03:56

Hi Pavel.

Could you give me some example?

(Sep 04 '14 at 23:58) Alexey Kulakov Alexey%20Kulakov's gravatar image

Thanks for example. This is really strange situation because on our side it works well. We are trying to find out why.

(Sep 08 '14 at 05:07) Alexey Kulakov Alexey%20Kulakov's gravatar image

Write me email on alexey.kulakov@dataobjects.net and we will discuss this issue.

(Sep 08 '14 at 06:13) Alexey Kulakov Alexey%20Kulakov's gravatar image

One Answer:

With a help of Alexey and after updating to 5.0.2 and carefully following the documentation this problem was solved.

Thanks!

answered Sep 16 '14 at 05:15

Pavel%20Kudinov's gravatar image

Pavel Kudinov
7335

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

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×56
×20

Asked: Sep 04 '14 at 08:23

Seen: 2,585 times

Last updated: Sep 16 '14 at 05:15

powered by OSQA