LINQ to SQL VS, association code generation warning

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
I-Vladimir
Posts: 10
Joined: Mon 23 Jan 2012 17:15

LINQ to SQL VS, association code generation warning

Post by I-Vladimir » Thu 24 May 2012 20:07

Hi,
Have table with primary key RowID, guid.
Another child table with the same primary key RowId and foreighn key to table 1. I.e. 1 to 1 relation, record in the second table is optional.
When I set default DeleteOnNull association property to False, Entity Developer generates a warning: Association 'Association_Name' is based on a non-nullable property(ies). In case any 'ObjectOne' object is removed ...
When I change it to True, no warnings, but I get exception
Invalid DeleteOnNull specification for member 'MyMember'. DeleteOnNull can only be true for singleton association members mapped to non-nullable foreign key columns.
Any way to disable that warning?
Thanks,

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Re: LINQ to SQL VS, association code generation warning

Post by StanislavK » Fri 25 May 2012 13:33

Thank you for the report, we have reproduced the problem with the exception being thrown. We will inform you when it is fixed.

At the moment, you can fix the mapping generated for the model manually. To do so, please find the mapping for the navigation property of the 'parent' entity (for example, it may look like '[Devart.Data.Linq.Mapping.Association(Name="Parent_Child"...' for the attribute mapping), and set 'DeleteOnNull' to false for it.

As for the warning, it is the expected behaviour. If, for example, the ObjectOne property is set to null in a 'main' object, the foreign key in the 'dependent' object should be set to null as well. Since the foreign key is not nullable (and, moreover, it is the primary key in this particular situation), this will lead to an error.

I-Vladimir
Posts: 10
Joined: Mon 23 Jan 2012 17:15

Re: LINQ to SQL VS, association code generation warning

Post by I-Vladimir » Fri 25 May 2012 14:01

The issue is that warning generated by the custom tool looks confusing. It suggests to set to True, that causing aplication exception.
I can change it to False from the properties.
Thanks again

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Re: LINQ to SQL VS, association code generation warning

Post by StanislavK » Fri 25 May 2012 14:22

Setting the DeleteOnNull option to true is the correct suggestion. The problem is that the mapping is generated with DeleteOnNull enabled for both 'parent' and 'child' sides (while it should be set to true at the 'child' side only).

At the moment, you can either disable DeleteOnNull at the 'parent' side manually, or ignore the warning.

Post Reply