Im hoping to get your help here. Im very new to EF and am having some troubles. I am using the Database First approach and have a database in Azure that I have to retreive data from.
[DataContract]
[Table("A")]
public class AgencyDC
{
[DataMember]
[Key]
public string AID { get; set; }
public string AName { get; set; }
public string GeneralEmailAddress { get; set; }
public string WebsiteURL { get; set; }
[DataMember]
[ForeignKey("AID")]
[IgnoreDataMember]
public virtual AExtensionDC AExtension { get; set; }
}
[DataContract]
[Table("AExtension")]
public class AExtensionDC
{
[DataMember]
[Key]
public string AID { get; set; }
[DataMember]
public bool? IsActive { get; set; }
public bool? IsOptedOut { get; set; }
public DateTime? LastUpdated { get; set; }
}
I am trying to use EF6 to retreive my records using DBSets in my context..
public List<ADataCcontract> GetAllAs()
{
using (AContext _aCtx = new AContext())
{
var mylist = _aCtx.A.Include("AExtension").ToList();
return mylist;
}
}
Now, I should be getting back 547 records back with only 1 of them having the AExtension navigational property having content within. The other 546 records should contain NULL. However, for some reason, I am only getting what appears to be a record that has a match in both tables. In SQL speak, I kind of just want a left join so that I return ALL rows from AE entity and OPTIONALLY matches in AE.
I hope this makes sense.
If possible, if you have a fix, could you please post an example I could referent? I am really stuck.