Turn the Pluralization On
. The problem is that you model object are using singular name (Pupil
) convention, while in your database you are using pluralized names Pupils
with s
.
UPDATE
This post shows how can you turn it on or off.
Some relevant excerpt of that post:
To turn pluralization on and off
On the Tools menu, click Options.
In the Options dialog box, expand Database Tools.
Note: Select Show all settings if the Database Tools node is not visible.
Click O/R Designer.
Set Pluralization of names to Enabled = False to set the O/R Designer so that it does not change class names.
Set Pluralization of names to Enabled = True to apply pluralization rules to the class names of objects added to the O/R Designer.
UPDATE 2
But note that, you should avoid pluralized names.
You can read here how to do it (I'll cite it here, just in case the link gets broken).
(...) When you work with Entity Framework Code First approach, you are creating your database tables from your model classes. Usually Entity Framework will create tables with Pluralized names. that means if you have a model class called PhoneNumber, Entity framework will create a table for this class called “PhoneNumbers“. If you wish to avoid pluralized name and wants singular name like Customer , you can do it like this
In your DBContext class, Override the “OnModelCreating” method like this (...)
(...) Having this Method Overriding will avoid creating tables with pluralized names. Now it will create a Table called “PhoneNumber” , Not “PhoneNumbers” (...)
See Inner Exception for details
means what it says. You are calling an objectdbo.Pupils
that doesnt exist. Did you have EF pluralize your tables for you? If so, the EF table might be something odd like "Pupilss". Usually the database table is singular and EF is pluralized. And having thedbo
in front of it is odd as well. – Himelman