title: ASP.NET MVC 4 Kendo Grid - ForeignKeyAttribute on property is not valid
body: <p>I am trying to navigate through a table in order to display the text value instead of the id and I get this error:</p>
  
  <blockquote>
    <p>An exception of type 'System.InvalidOperationException' occurred in
    EntityFramework.dll but was not handled in user code</p>
    
    <p>Additional information: The ForeignKeyAttribute on property
    'languageId' on type 'DevelopmentNotesProject.Models.NoteForm' is not
    valid. The navigation property 'Language' was not found on the
    dependent type 'DevelopmentNotesProject.Models.NoteForm'. The Name
    value should be a valid navigation property name.</p>
  </blockquote>
  
  <p>It's been some hours that I've been trying to solve the problem in vain ...
  Thanks a lot for your time
  This is my code:</p>
  
  <p>View:</p>
  
  <pre><code>@using Kendo.Mvc.UI
  @model DevelopmentNotesProject.Models.NoteForm
  
  @{
      ViewBag.Title = "Index";
  }
  
  
  &lt;script type="text/javascript"&gt;
      function formatter(value) {
          return value.substring(0, 50);
      }
  &lt;/script&gt;
  
  
  &lt;section id="listing"&gt;
      &lt;h2&gt;My Notes&lt;/h2&gt;
  
          @(Html.Kendo().Grid&lt;DevelopmentNotesProject.Models.NoteForm&gt;()
          .Name("grid")
          .Columns(columns =&gt;
          {
              columns.Bound(c =&gt; c.Title).Width(200).ClientTemplate(string.Format("{0}...", "#= formatter(Title) #"));
              columns.Bound(c =&gt; c.Text).Width(450).ClientTemplate(string.Format("{0}...", "#= formatter(Text) #"));
              columns.ForeignKey(p =&gt; p.languageId, (System.Collections.IEnumerable)ViewData["lang"], "Id", "Name").Title("Language").Width(100);
              columns.Command(command =&gt; { command.Edit(); command.Destroy(); });
  
          })
          .HtmlAttributes(new { style = "height: 380px;" })
          .Scrollable()
          .Groupable()
          .Sortable()
          .Pageable(pageable =&gt; pageable
              .Refresh(true)
              .PageSizes(true)
              .ButtonCount(5))
           .DataSource(dataSource =&gt; dataSource // Configure the grid data source
                    .Ajax() // Specify that ajax binding is used
                    .Read(read =&gt; read.Action("Notes_Read", "MyNotes")) // Set the action method which will return the data in JSON format
                    .Destroy(update =&gt; update.Action("Notes_Destroy", "MyNotes"))
                    .Update(update =&gt; update.Action("Notes_Update", "MyNotes"))
                    .Model(model =&gt; 
                        {
                            model.Id(p =&gt; p.id);
                        })
                 )
           .Selectable()
          )
  
  
  
    &lt;/section&gt;
  
  @Html.ActionLink("Add a new note", "Add", "MyNotes")
  
   @section Scripts {
          @Scripts.Render("~/bundles/jqueryval")
      }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Index()
  {
      var dbo = new UsersContext();
      ViewData["lang"] = dbo.Language.Select(b =&gt; new { Id = b.id, Name = b.lang });
      return View();
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Data.Entity;
  using System.Globalization;
  using System.Web.Security;
  
  namespace DevelopmentNotesProject.Models
  {
      public class UsersContext : DbContext
      {
          public UsersContext()
              : base("DefaultConnection")
          {
          }
  
          public DbSet&lt;UserProfile&gt; UserProfiles { get; set; }
          public DbSet&lt;Language&gt; Language { get; set; }
          public DbSet&lt;NoteForm&gt; Note { get; set; }
      }
  
      [Table("note")]
      public class NoteForm
      {
          [Required]
          [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
          [Display(Name = "Title")]
          public string Title { get; set; }
  
          [Required]
          [Display(Name = "Text")]
          public string Text { get; set; }
  
          [Required]
          [Display(Name = "Language")]
          [ForeignKey("Language")]
          public int languageId { get; set; }
  
          [Key]
          public int id { get; set; }
  
          public int userId { get; set; }
  
      }
      [Table("Language")]
      public class Language
      {
          public string lang { get; set; }
  
          [Key]
          public int id { get; set; }
      }
  
  }
  </code></pre>