Home > Net >  How to fix this error: Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name '
How to fix this error: Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name '

Time:10-07

My application runs off my database that I created. I added migration, update-database and all that jazz so that it works perfectly fine. Now that I have to convert my project to use the LIVE database, I'm getting this error message:

Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'NormalizedEmail'.
Invalid column name 'ConcurrencyStamp'.
Invalid column name 'LockoutEnd'.
Invalid column name 'NormalizedEmail'.
Invalid column name 'NormalizedUserName'.
Invalid column name 'UserType'.

I'm not sure how to go about fixing this but when I use my old database it works, with this new one it just keeps giving me this error when I try to log in a user or anything to do with my database.

Help please!

ThANK YOU!

CodePudding user response:

Remove this columns from code I think it's mismatch with database

look at this

CodePudding user response:

The problem is very simple to state and very difficult to solve. But there IS a solution.

Manual solution

If all automatic approaches fail and you do not have any extra information, then you can at least ensure that your schema is technically compatible with the application's expectations.

Depending on the RDBMS that you use and which was not specified in the question, you can get all the table names and column names. In MySQL and PostgreSQL you could query information_schema.columns, in SQL Server you can join sys.tables and sys.columns for that purpose. Make sure that you order the results by tablename, columnname and export it. Do it both for your old db and prod db. Find out what the differences are and implement alter statements to add the missing columns.

Automatic solution

If you have some scripts versioned somewhere that were doing the alters and possibly filling the new columns with data, then run those either by hand or a migration tool. Make sure that if such files exist, then you find them.

Removal

You can also remove the column references from code, as Cemil suggested in his/her answer, but you should avoid doing this, unless you are absolutely sure that it is feasible for your situation. The basic assumption is that the code references these for a reason and you are missing the columns from the database where they need to be created. Do not remove the column references from code until this basic assumption is proven wrong.

  • Related