Page 1 of 1

Initial NavigationProperty Collections to empty collection

Posted: Thu 11 Dec 2014 09:54
by jongleur
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

Re: Initial NavigationProperty Collections to empty collection

Posted: Thu 11 Dec 2014 12:14
by jongleur
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

Re: Initial NavigationProperty Collections to empty collection

Posted: Fri 12 Dec 2014 16:28
by Shalex
We will improve a predefined DbContext template to initialize the collection if ProxyGenerationEnabled=True (default value) as well and notify you.

Re: Initial NavigationProperty Collections to empty collection

Posted: Thu 15 Jan 2015 15:09
by Shalex
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.