locked
Invalid column name 'UserId'. RRS feed

  • Question

  • User-641348095 posted

    Hello,

    I am using ASP MVC ENTITY FRAMEWORK CODE FIRST. I have a table called "Voiture" which contains 4 fields. I am trying now to add a new field UserID by writing this in my Class Voiture.cs :

    [Required]
    public String UserId { get; set; }

    in order to show only the data related of the logged User, I wrote this in my Controller :

     return View(db.Voitures.Where(a => a.UserId == HttpContext.User.Identity.Name).ToList());

    but I got always this Error :

    Invalid column name 'UserId'.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'UserId'.
    

    Thursday, August 24, 2017 7:41 AM

Answers

All replies