Simple One-To-One association. Exception occurs after association replace and entity remove.
No exception with ServerProfile-Session! Exception:Referential integrity violation on attempt to remove 'Model.TestA', Key='TestA, (769)'. Association: TestB-TestA-TestA (AssociationInfo) Referencing Entity Key: TestB, (771) Referenced Entity Key: TestA, (769) Example:[Serializable] [HierarchyRoot] public class TestA : Entity { public TestA( Session session ) : base( session ) { } [Field, Key] public int Id { get; private set; } [Field] public string Text { get; set; } } [Serializable] [HierarchyRoot] public class TestB : Entity { public TestB( Session session ) : base( session ) { } [Field, Key] public int Id { get; private set; } [Field] public string Text { get; set; } [Field] public TestA TestA { get; set; } } // Create data Xtensive.Orm.Key KeyA2, KeyB; using( var session = domain.OpenSession( new SessionConfiguration( SessionOptions.ServerProfile ) ) ) { using( var transaction = session.OpenTransaction() ) { var TestA1 = new TestA( session ) { Text = "A1" }; KeyA2 = new TestA( session ) { Text = "A2" }.Key; KeyB = new TestB( session ) { Text = "B1", TestA = TestA1 }.Key; transaction.Complete(); } } // Exception using( var session = domain.OpenSession( new SessionConfiguration( SessionOptions.ClientProfile ) ) ) { var TestA2 = session.Query.Single<TestA>( KeyA2 ); var TestB = session.Query.Single<TestB>( KeyB ); var TestA1 = TestB.TestA; // Changing association TestB.TestA = TestA2; // Remove entity -> Exception! TestA1.Remove(); } |
Thank you for report, TeaMan.