ObservableCollection navigation properties are null

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
[email protected]
Posts: 10
Joined: Wed 29 Jun 2016 13:34

ObservableCollection navigation properties are null

Post by [email protected] » Fri 01 Jul 2016 15:20

Hello - I'm getting null exceptions when trying to reference entity ObservableCollection navigation properties in a dotConnect for PostgreSQL/Entity Data Model/DbContext generated code. I downloaded the latest version a couple of days ago. I can only guess it's because of the following.

When using ADO.Net Data Model, the MS-generated code for the entities includes the creation of the ObservableCollection navigation properties. I have never had an exception trying to reference the navigation property in this model, presumably because it's been created when the entity was created:

Code: Select all

   public partial class BCFuturesExpiration
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public BCFuturesExpiration()
        {
            this.HistoricalUpdateAttempted = false;
            this.BCHistoricalBars = new ObservableCollection<BCHistoricalBar>();
        }
Using dotConnect for PostgreSQL, database-first Entity Data Model, and the DbContext template, these navigation properties aren't created:

Code: Select all

   public partial class BCFuturesExpiration    {

        public BCFuturesExpiration()
        {
          this.HistoricalUpdateAttempted = false;
          this.Intradayupdateattempted = false;
            OnCreated();
        }
...
       /// <summary>
        /// There are no comments for BCHistoricalBars in the schema.
        /// </summary>
        public virtual ObservableCollection<BCHistoricalBar> BCHistoricalBars
        {
            get;
            set;
        }
Is there a way I can modify the template to make sure these properties are created? Or is there something else I should be doing?

Thanks,

Brian

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

Re: ObservableCollection navigation properties are null

Post by Shalex » Mon 04 Jul 2016 14:10

Thank you for your report. We will notify you when the DbContext template is fixed.

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

Re: ObservableCollection navigation properties are null

Post by Shalex » Thu 07 Jul 2016 17:03

The behaviour is changed: the ObservableCollection navigation properties are initialized now in a default class constructor (Entity Framework models). The change is available in the newest (7.6.687) build of dotConnect for PostgreSQL.

Post Reply