Why do I get "Invalid Column Name" errors in EF4?
- by camainc
I am trying to learn Entity Framework 4.0.
Disclaimer 1: I am brand new to Entity Framework. I have successfully used LinqToSQL.
Disclaimer 2: I am really a VB.Net programmer, so the problem could be in the C# code.
Given this code snippet:
public int Login(string UserName, string Password)
{
return _dbContext.Memberships
.Where(membership => membership.UserName.ToLower() == UserName.ToLower()
&& membership.Password == Password)
.SingleOrDefault().PrimaryKey;
}
Why do you suppose I get "Invalid column name" errors?
{"Invalid column name 'UserName'.\r\nInvalid column name 'Password'.\r\nInvalid column name 'UserName'.\r\nInvalid column name 'Password'."}
Those column names are spelled and cased correctly. I also checked the generated code for the entity in question, and those columns are properties in the entity. The intellisense and code completion also puts the column names into the expression just as they are here.
I am stumped by this. Any help would be much appreciated.
https://docs.google.com/leaf?id=0B-xLbzoqGvXvNjBmZmNjNDAtY2RhNC00NDA2LWIxNzMtYjhjNTYxMDIyZmZl&hl=en