whoah
whoah

Reputation: 4443

update-database - column does not exist

When I tried to use update-database -verbose -force, I get an error:

ALTER TABLE DROP COLUMN failed because column 'countReferralsRegistrations' does not exist in table 'UserProfile'.

The problem is - I don't have (and I don't want to have) this column in model and also in table UserProfile.

How can I resolve it?

Upvotes: 3

Views: 5707

Answers (2)

Viranja kaushalya
Viranja kaushalya

Reputation: 785

This will happen, because you may delete your Table column's manually and will update the database,

This is the solution for this. - Open the migration file which you created at last. - comment below lines and update-database again - DropForeignKey, DropIndex, DropColumn

Thank You..

Upvotes: 0

whoah
whoah

Reputation: 4443

SOLUTION

use first: Add-Migration InitialMigrations -IgnoreChanges and then update-database verbose. This will work

Upvotes: 3

Related Questions