I renamed a table from my database. So I also renamed my entity (from Favori to FavorisAffaire). Compiled successfully. But now, when I run my application, I get the error below:
Invalid object name ‘dbo.FavorisAffaires’
I didn’t have this FavorisAffaires in my solution!
I have FavorisAffaire (withount ending s). I suspect something is wrong in the background of my solution… I already try a clean followed by a rebuild but the problem is still there.
Any ideas?
That is how EF behaves by default. It uses pluralization of names. It can be turned off or you can force single entity to map to proper table but that all depends on the version of EF you are using.
Edit:
Yes you forgot to mention very important part of your question.
There are several ways to do that.
Data annotation:
Or fluent mapping:
Or removing pluralization convention (this has global scope so it can break mappings of other existing tables)
Once you remove convention you should ensure that name of
DbSetis singular:Or simply rename your table because tables should be plural.