title: Entity Framework to TreeView MVC
body: <p>I am developing an ASP.NET MVC web application in which I am accessing a SQL database to retrieve information from a table.</p>
  
  <p>The information is accessed from SQL (one single table) using Entity Framework. Each item in the framework entity contains ID, ParentID and name.</p>
  
  <p>In my application so far, I can print every item in Entity Framework and its information (using a for loop).</p>
  
  <p>I would like to generate a TreeView (using Telerik-open to other options please) to display each item, and its respective children items (we can figure that out from ParentID). </p>
  
  <p>I had a look at demos on the telerik website, like this one:<a href="https://demos.telerik.com/aspnet-mvc/treeview/local-data-binding" rel="nofollow noreferrer">https://demos.telerik.com/aspnet-mvc/treeview/local-data-binding</a></p>
  
  <p>But no demo seemed to apply to my case, as the data that is contained in Entity Framework is dynamic (it will not always be the same, sometimes they will be more or less levels in the tree,etc), so we cannot hard code the tree elements.</p>
  
  <p>Does anyone know if this can be done?</p>
  
  <p>Thanks a lot.</p>