The model contains two entities: 1) Entity A with paired association to entity B 2) Entity B with not nullable field and paired association to entity A After creating entity B we can set its fields to some values before persisting it to database. But in case of paired field there is one more update for linked entity that causes persisting all changes (even uncompleted). I have faced this problem after setting field in constructor but it can be reproduced with simple property setters Code sample to reproduce the issue: namespace Sample {
} On some iteration (it may be 499, 251 or something else) there is exception: Xtensive.Orm.CheckConstraintViolationException: SQL error occured. Storage error details 'Entity: LinkEntity; Field: Str (FieldInfo);' SQL error details 'Type: CheckConstraintViolation; Table: LinkEntity; Column: Str;' Query 'INSERT INTO [dbo].[LinkEntity] ([Id], [Str], [EntityWithVersion.Id]) VALUES (@p1_0, @p1_1, @p1_2); ... INSERT INTO [dbo].[LinkEntity] ([Id], [Str], [EntityWithVersion.Id]) VALUES (@p25_0, @p25_1, @p25_2); [p1_0='35ae1f7f-4e17-4f6a-90a8-0993ab98f1fb';p1_1='';p1_2=''; ... p25_0='0facc445-2760-47dc-a5cc-909bb4a13e22';p25_1='test';p25_2='ce3808f0-0d4d-45b5-b2a7-7a0b8e67c615' ]' Original message 'Cannot insert the value NULL into column 'Str', table 'DO40-Tests.dbo.LinkEntity'; column does not allow nulls. INSERT fails. The statement has been terminated.' ---> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Str', table 'DO40-Tests.dbo.LinkEntity'; column does not allow nulls. INSERT fails. ... One more issue here is displaying empty string ('') instead of NULL in SQL Query text (SQL Profiler shows NULL) Any fast workaround is appreciated |