Hi,
I changed a database table (both updated and dropped and recreated the table). Somehow, running the command in the package manager console:
Update-Database -context <contextname>
says that "No migrations were applied. The database is already up to date."
So, I changed the context manually.
When I execute context.savechanges(), it says "invalid column name 'column1'", but column1 does not exist in the current table. It did exist in the previous version before I dropped and recreated the table. 'column1' is a foreign key - referencing another column.
I have not been able to establish this FK relationship in the context
entity.HasOne(d => d.TableNameForeignKeyReferenceTable)
.WithMany(p => p.TableName)
.HasForeignKey(d => d.foreignKeyColumn)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("foreignkeyname");
thus,
entity.HasOne(d => d.PersonAliasPerson) /* compiler is not recognizing this */
.WithMany(p => p.PersonAlias)
.HasForeignKey(d => d.PersonId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_PersonAlias_Person");
Table Structure
=============
Person
=============
PersonId
DL
SSN
PersonAlias
=============
PersonAliasId
PersonId
LastName
FirstName
Thank you
tinac99