I am encountering an error to the effect of "A specified Include path is not valid. The EntityType 'MyCMS.DAL.SiteSettings' does not declare a navigation property with the name 'SiteSettingOptions'."
I have read quite a few posts about this issue but all of the research I have done pertains to ICollections and not for properties that are classes.
Here is where I am and could use your help resolving the issues.
[Table("SiteSettingsBridge")]
[DataContract]
public partial class SiteSettings
{
[Key]
[DataMember]
public int SiteSettingsBridgeID { get; set; }
[DataMember]
public int SiteID { get; set; }
[DataMember]
public int SiteSettingOptionID { get; set; }
[DataMember]
public virtual SiteSettingOptions SiteSettingOption { get; set; }
[DataMember]
[StringLength(500)]
public string Value { get; set; }
public SiteSettings()
{
SiteSettingsBridgeID = 0;
SiteID = 0;
SiteSettingOptionID = 0;
Value = "";
}
}
[DataContract]
public partial class SiteSettingOptions
{
[Key]
[DataMember]
public int SiteSettingOptionID { get; set; }
[DataMember]
public string SettingsGroup { get; set; }
[DataMember]
[StringLength(100)]
public string Name { get; set; }
[DataMember]
[StringLength(500)]
public string DefaultValue { get; set; }
[DataMember]
public SettingType Type { get; set; }
public enum SettingType
{
String = 1,
Bool = 2,
Integer = 3
}
public SiteSettingOptions()
{
SiteSettingOptionID = 0;
SettingsGroup = string.Empty;
Name = string.Empty;
DefaultValue = string.Empty;
Type = SiteSettingOptions.SettingType.String;
}
}
and then in my DAL project, I am attempting to add an Include to the context query like this
public static List<Contracts.Sites.SiteSettings> GetBySiteID(int SiteID)
{
using (CMSContext cntx = new CMSContext())
{
///OMITTED FOR BREVITY
return cntx.SiteSettings.Include("SiteSettingOptions").Where(i => i.SiteID == SiteID).ToList();
}
}
When I compile and run, I am receiving the above error.
To answer a few questions up front, I am not using LazyLoading and I am not doing anything on model create.
Yes, I am brand new to EF. This is my first app.