Closed mspace23 closed 8 years ago
Have a look at the documentation for IQueryable.Include
, and these examples.
Include is expecting the name of a navigation property which will effectively join 2 tables together. You are specifying Url
as that property. However, your entity does not have a navigation property named Url
. Note the following example.
public class Article
{
public int ArticleId { get; set; }
public string ArticleTitle { get; set; }
public virtual ICollection<Url> Url { get; set; }
}
public class Url
{
public int UrlId { get; set; }
public string ArticleUrl { get; set; }
}
Note that you only need to join tables if the Url
field is in a different table than SiteContents
. Most likely in this scenario your ArticleUrl
is in the Article
table, so you probably don't need to do this.
I am closing this question because it is not about MvcSiteMapProvider
, it is about Entity Framework. If you have any other questions about Entity Framework, I suggest you post them on StackOverflow.
ok thank you for your reply. I have another issue now I have post it at stackoverflow. Could you help out? [http://stackoverflow.com/questions/35622970/dynamic-sitemap-from-database-doesnt-display-the-nodes] thank you again
hello thank you for this tutorial. I getting this error Additional information: A specified Include path is not valid. The EntityType 'MyProjectName.Models.MyTable' does not declare a navigation property with the name 'Url'.
My class code:
what type of data should I have at foreach (var article in mydbcs.SiteContents.Include("Url"))