SqlException: Invalid column name GolferId

Posted by

EF6 Core – reconfiguring navigation properties, the runtime was complaining about a column GolferId being missing (invalid database column).

Took me a minute to figure out and remember the default foreign key dependency naming convention in EF. Sometimes these frameworks are a bit too intelligent for my taste.

Turns out the EF was guessing that if I have a navigation property to a related entity called “User” – the framework will automatically use an object property field called “UserId” :/ … easily solved with the ForeignKey tag 🙂

https://stackoverflow.com/questions/46091157/changing-default-column-name-for-navigation-property

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s