locked
Error - Invalid column name Active RRS feed

  • Question

  • User1979860870 posted

    Hi

       After changing from Ative to Active i am getting above error

            public Employee()
            {
                CreatedOn  = DateTime.Now;
            }
            public string Id { get; set; }
            public string Name { get; set; }
            public string Address { get; set; }
            public string Gender { get; set; }
            public string Designation { get; set; }
    
            [Display(Name = "Date Of Birth")]
            [DataType(DataType.Date)]
            [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
            public DateTime Dob { get; set; }
    
            public string Active { get; set; }
        }

    Thanks

    Wednesday, February 10, 2021 4:52 AM

All replies

  • User1686398519 posted

    Hi jagjit saini, 

    Where did you get this error? Is it the error message you get when getting data from the database?

    Best Regards,

    YihuiSun

    Wednesday, February 10, 2021 6:14 AM
  • User1979860870 posted

    Hi YihuiSun

       When below code gets executed

    private PMDbContext db = new PMDbContext();
    
            // GET: api/Employees    
            public IEnumerable<Employee> GetEmployee()
            {
                return db.Employees.ToList();
            }
    

    Thanks

    Wednesday, February 10, 2021 7:12 AM
  • User1686398519 posted

    Hi jagjit saini,

    Did you update the database when you changed from "Ative" to "Active"?

    If not, you need to run the following command in the package manager console to update the database:

    1. Enable-Migrations -EnableAutomaticMigrations -Force
    2. Add-Migration Initial
    3. Update-Database -Verbose

    Best Regards,

    YihuiSun

    Wednesday, February 10, 2021 7:44 AM
  • User1979860870 posted

    Hi YiHuiSun

      O.k . But in Database this field already exists.

    Issue was in Model it was Ative ,i changed it to Active then this problem start coming.

    Secondly i have Records already in Database . 

    Thanks

    Wednesday, February 10, 2021 9:03 AM
  • User1686398519 posted

    Hi jagjit saini, 

    Database this field already exists.

    Are you using the Code First workflow?You'd better use the commands in the package manager console to update the database I mentioned earlier.

    I found a similar problem, you can check your code according to the tips in this link.

    Best Regards,

    YihuiSun

    Thursday, February 11, 2021 6:03 AM