title: Invalid column name Error while trying to access EF CodeFirst Database
body: <p>I am trying to access EF tables using the following code</p>
  
  <pre><code>public void UserLogin(string UserId, string Password)
          {
              var ErrorMessage = "";
              int ErrorCode = 0;
              var result = db.Users.Where(x =&gt; (x.LoginId.Equals(UserId) &amp;&amp; x.Password.Equals(Password)));
              var favourites = db.Favourites.Where(x =&gt; x.LoginId.Equals(UserId)).ToList();
  
      }
  </code></pre>
  
  <p>i have used <code>table["Table name"]</code> option still showing same error</p>
  
  <p>In favorites table I am getting the following error - </p>
  
  <pre><code>{"Invalid column name 'LoginId'.\r\n
    Invalid column name 'LoginId'.\r\n
    Invalid column name 'LoginId'.\r\n
    Invalid column name 'Name'.\r\n
    Invalid column name 'StockExchange'.\r\n
    Invalid column name 'Symbol'."}
  </code></pre>
  
  <p>This is how my Favorites model look - </p>
  
  <pre><code>[Table("Favourites")]
      public class Favourites
      {
  
           [Key]
           public int FavId { get; set; }
           public String LoginId { get; set; }
           public String LastTradePriceOnly { get; set; }
           public String Name { get; set; }
           public String StockExchange { get; set; }
           public String Symbol { get; set; }
           public String MarketCapitalization { get; set; }
  
  
      }
  </code></pre>
  
  <p>And this is my Data Definition of the table - </p>
  
  <pre><code>CREATE TABLE [dbo].[Favourites] (
      [FavId ]               INT            IDENTITY (1, 1) NOT NULL,
      [ LoginId]             NVARCHAR (MAX) NULL,
      [LastTradePriceOnly]   NVARCHAR (MAX) NULL,
      [ Name]                NVARCHAR (MAX) NULL,
      [ StockExchange]       NVARCHAR (MAX) NULL,
      [ Symbol ]             NVARCHAR (MAX) NULL,
      [MarketCapitalization] NVARCHAR (MAX) NULL,
      CONSTRAINT [PK_Favourites] PRIMARY KEY CLUSTERED ([FavId ])
  );
  </code></pre>
  
  <p>What am I doing wrong? How can I fix the error?</p>