Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referenced table is not coming in my model through entity framework 5.0

I am using MVC 4 and entity framework 5.0, i have a database and this database contains 6 tables named as following.

tblUser_family
tblUser_location
tblUser_info
tblUser_photo
tblUser_settings
tblUser_social

when i am creating the .edmx file then only 5 tables are coming in designer one table "tblUser_settings" is not coming, while all tables are connected through foreginKeys.

I am getting following error

Error 1 Error 6004: The table 'Community.dbo.tblUser_settings' is referenced by a relationship, but cannot be found.

like image 465
Ashish-BeJovial Avatar asked May 25 '15 05:05

Ashish-BeJovial


People also ask

How do I insert a table into Entity Framework?

Open edmx file, right click anywhere in the modal and select "Update Model from Database" and follow the instructions and choose the desired tables and SPs. Sometimes even after following these steps, your model will not get updated, close Visual Studio and restart it again.

How do I update table mapping in Entity Framework?

The easiest way to resolve this issue is to right click on the Entity Model and choose "Update Model From Database". Then select the "Refresh" tab and find and select only the table you wish to map a column for. Click the Finish button and you should have everything properly mapped.


4 Answers

Recently i have resolved my issue, problem was i had a main table which has a primary key, and that primary key was mapped with my missing table's column in that column i set "Allow null", as i changed "Allow not null", and update my data model from Entity framework 5.0, it was visible in my solution.

Thank you for all suggestions.

like image 93
Ashish-BeJovial Avatar answered Oct 07 '22 16:10

Ashish-BeJovial


I had this problem, in my case I didn't have created the primary key to my table, so I just set it and I could update my EDMX.

like image 30
Tiago Ávila Avatar answered Oct 07 '22 18:10

Tiago Ávila


make sure you have "not null" in the declaration of FK

like image 27
Alejandro Muñoz Avatar answered Oct 07 '22 18:10

Alejandro Muñoz


My issue was when creating the foreign keys I didn't specify NOT NULL. I made the change and the table imported just fine.

like image 23
user3669766 Avatar answered Oct 07 '22 16:10

user3669766