ObservableCollection navigation properties are null
Posted: 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:
Using dotConnect for PostgreSQL, database-first Entity Data Model, and the DbContext template, these navigation properties aren't created:
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
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>();
}
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;
}
Thanks,
Brian