Initial NavigationProperty Collections to empty collection

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
jongleur
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Initial NavigationProperty Collections to empty collection

Post by jongleur » Thu 11 Dec 2014 09:54

We try to Switch from the EF Provider developed by Oracle to dotconnect for Oracle 8.4 to use it in EntityFramework.
After solving several issues during Migration I see a difference in the generated Code of the C# classes that is annoying.

Navigation Properties of 1-to-many-associations are of Type Collection<MyEntity>, which is fine, but in contrast to Oracles Provider dotConnect seems not to initialize those to an empty collection.

As a result the property returns null and therefore it is not possible to query it without checking for null.

Is it possible to configure the DbContext Code Generator to somehow add an initialization to Collection properties that creates an empty Collection?

regards
Peter

jongleur
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Re: Initial NavigationProperty Collections to empty collection

Post by jongleur » Thu 11 Dec 2014 12:14

Disabling ProxyGenerationEnabled seems to solve this issue, but I don't understand why the Generation of proxies should affect the initialization of collections.

Is this the right way to solve the issue?

regards
Peter

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

Re: Initial NavigationProperty Collections to empty collection

Post by Shalex » Fri 12 Dec 2014 16:28

We will improve a predefined DbContext template to initialize the collection if ProxyGenerationEnabled=True (default value) as well and notify you.

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

Re: Initial NavigationProperty Collections to empty collection

Post by Shalex » Thu 15 Jan 2015 15:09

Shalex wrote:We will improve a predefined DbContext template to initialize the collection if ProxyGenerationEnabled=True (default value) as well and notify you.
A deeper investigation concluded that the collection should not be initialized explicitly when ProxyCreationEnabled=True. Please use ProxyCreationEnabled=False.

Post Reply