Omitting DataMember on reverse navigation properties

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
magnus
Posts: 11
Joined: Mon 22 Aug 2011 11:07

Omitting DataMember on reverse navigation properties

Post by magnus » Thu 25 Apr 2013 06:54

We have a change request for the DbContext template that may put us in the minority, but we would like to have the option of omitting the DataMember attribute on reverse navigation properties when using the WCF Data Contract option in the DbContext template, but we do want the attribute on regular properties, and of course on regular entity fields.

As an example, if there's an entity Order and another entity OrderLine, and OrderLine has a foreign key to Order, we want the Order property on the OrderLine entity to have DataMember, but the OrderLines property on the Order entity should not.

We have two reasons for this:
1. We're using the entity classes as DTO classes as well as in our internal code, and although we do use the navigation properties internally, we have no desire to expose the reverse navigation properties to anyone else.
2. We experienced some pretty severe issues when trying to import WSDLs using the data contract hierarchies with reverse navigation properties into SoapUI, presumably owing to the complexity of the hierarchy or possibly something to do with circular references. This may just be a bug with that program, but we can't be certain that the same problem won't affect other programs -- particularly other Java-based programs.

We've implemented this as a one-liner in our modified version of the DbContext template, although I'm sure that if you were to implement this it would have to be as a configurable option.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Omitting DataMember on reverse navigation properties

Post by Shalex » Mon 29 Apr 2013 14:01

magnus wrote:we would like to have the option of omitting the DataMember attribute on reverse navigation properties
Thank you for your suggestion. We will investigate the possibility of implementing the corresponding option.

Could you please tell us your opinion concerning the many-to-many association because there is no way to distinguish reverse and direct properties for this type of association?

magnus
Posts: 11
Joined: Mon 22 Aug 2011 11:07

Re: Omitting DataMember on reverse navigation properties

Post by magnus » Wed 08 May 2013 09:27

Thanks for the reply. My personal feeling is that DataMember should be omitted on many-to-many associations since they are effectively relations that are "reverse on both sides".

By the way, this is how we implemented this in our little hack:

Code: Select all

if (WcfDataContractAttributes)
  if (relationProperty.Multiplicity != Multiplicity.Many)
    GenerateRelationWcfDataContractAttributes(relationProperty);
We added the second if-statement.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Omitting DataMember on reverse navigation properties

Post by Shalex » Mon 27 May 2013 07:07

The "WCF DataMember Attribute on Navigation Properties" property is added to the DbContext and POCO templates for pointing the end (-s) where the attribute should be generated. We will post here when the corresponding build of Entity Developer is available for download.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Omitting DataMember on reverse navigation properties

Post by Shalex » Thu 30 May 2013 14:24

New build of Entity Developer 5.5.115 is available for download now!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=32&t=27232.

Post Reply