Entity Framework : Invalid Column after removing the column

c# entity-framework

Question

I have a table mapped in Entity Framework which works great adding/updating and deleting records. I removed a column from SQL sever called "Category", then re-mapped my entity in the model. This worked fine, the column disappeared.

Now, I run a query on the table to update a row and get the same error, invalid column "Category".

This has been removed from the SQL table and removed from the Entity, so is it still looking for this damn column when I run the following code??

using (Entities db = new Entities())
                { 
                       var Voucher = (from vouchers in db.Vouchers
                                 where vouchers.ID == ID
                                 select vouchers).FirstOrDefault();

                       if (Voucher != null)
                       {
                           Voucher.Status = (int)Vouchers.UI.Enums.VoucherStatus.Removed;                           
                           ret = db.SaveChanges() == 1;
                       }
                } 

Here is the error:

Invalid column name 'Category'.

I have cleaned the code, built, re-built, and updated the enitties about a 100 times.

Does anyone have any ideas?

Thanks

1
12
7/25/2012 11:00:00 AM

Accepted Answer

Remove the table from the *.EDMX file, and then add that table again to the *.EDMX file

23
7/25/2012 11:02:47 AM

Popular Answer

I used to also remove and re-add table, but never like this. What I rather do. I close model. right click and open as XML and them manually remove this reference. So it keeps my multiple diagrams within one model same and also my defined colors.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow