title: LINQ to Entities does not recognize the method 'Int32 Int32(System.String)' method, and this method cannot be translated into a store expression
body: <p>I am trying to Query Database Context using Linq to Entities and I am getting this error:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'Int32 Int32(System.String)' method, and this method cannot be translated into a store expression.`</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>public IEnumerable&lt;CourseNames&gt; GetCourseName()
  {
     var course = from o in entities.UniversityCourses
                  select new CourseNames
                  {
                      CourseID = Convert.ToInt32(o.CourseID),
                      CourseName = o.CourseName,
                   };
     return course.ToList();
  }
  </code></pre>
  
  <p>I tried like this after seeing <a href="https://stackoverflow.com/questions/12278611/linq-to-entities-does-not-recognize-the-method-int32-int32system-string-meth">this</a></p>
  
  <pre><code>public IEnumerable&lt;CourseNames&gt; GetCourseName()
  {
      var temp = Convert.ToInt32(o.CourseID);
      var course = from o in entities.UniversityCourses
                   select new CourseNames
                   {
                       CourseID = temp,
                       CourseName = o.CourseName,
                   };
      return course.ToList();
  }
  </code></pre>
  
  <p>But it throws an error:</p>
  
  <blockquote>
    <p>"The name 'o' does not exist in the current context"</p>
  </blockquote>
  
  <p>This is my code for the class <code>GetCourseName</code></p>
  
  <pre><code>namespace IronwoodWeb
  {
      public class CourseNames
      {
          public int CourseID { get; set; }
          public string CourseName { get; set; }
      }
  }
  </code></pre>