Monday, September 8, 2014

LINQ to Entities does not recognize the method 'System.Object get_Item(System.String)' method, and this method cannot be translated into a store expression.

The Linq query is ultimately transformed into an SQL query and LINQ doesn't know what to do with Session["UserName"] (that gets the "UserName" item).

A common way to workaround this is just to use a local variable to which you'll assign Session["UserName"] and that you'll use in your Linq query...


string loggedUserName = Session["LogedUsername"].ToString();
  var userdetail =
dc.faculties.Where(a => a.F_UserName.Equals(loggedUserName)).FirstOrDefault();

Unable to load the specified metadata resource

MetadataException: Unable to load the specified metadata resource

This means that the application is unable to load the EDMX.

There are several things which can cause this, but most likely, due to invalid connection string. 

Possible Solutions:

1.Check connection string 
2.Refresh model.edmx
3.Select option "Update Model from database"  in model.edmx