Home > DeveloperSection > Forums > Database not working after updating the table in Visual studio 2012
Simond Gear
Simond Gear

Total Post:9

Points:63
Posted on    March-25-2016 3:13 AM

 ASP.NET MVC C#  ASP.Net  Database  ASP.NET MVC  Entity Framework 
Ratings:


 1 Reply(s)
 237  View(s)
Rate this:
Hi All,
I have getting error after updating tables directly in sql server 2012, it will through error in my MVC application. Error is below:

Server Error in '/' Application. Invalid column name 'Id'. Invalid column name 'Id'.


Here, My Table is below:


CREATE TABLE [dbo].[Course](
       [ID] [int] IDENTITY(1,1) NOT NULL,
       [Title] [nvarchar](50) NULL,
       [Credits] [int] NOT NULL,
       [DepartmentID] [int] NOT NULL,
 CONSTRAINT [PK_dbo.Course] PRIMARY KEY CLUSTERED
(
       [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


Please can anyone help.

Thank you.




Anupam Mishra

Total Post:135

Points:949
Posted on    March-25-2016 4:04 AM

Hi Simond,

 If you are using edmx, Then follow the following steps:

 1. Open edmx diagram & Delete the Course table diagram
 2. Add the Course  table once again
 3.  save and build the application
 4. Debug the project

Otherwise, if you are using CodeFirst Approach then, you need to update the database.

Modified On Mar-25-2016 04:06:20 AM

Don't want to miss updates? Please click the below button!

Follow MindStick