Reputation: 1867
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.
Upvotes: 9
Views: 11932
Reputation: 7
I also faced the same issue of not getting data from the reference table connected through a foreign key with the primary table. When I was trying to get the table data from DbContext class. Previously I was fetching the data using:
orders = _context.Orders.ToList();
I am not getting the reference table data. Hence, I used the "Include" functionality.
orders = _context.Orders.Include(p => p.Person).ToList();
This solution worked for me.
Upvotes: -1
Reputation: 1
For foreign keys, I didn't specify NOT NULL in reference tables. I updated table and update edmx file to resolve the issue.
Upvotes: 0
Reputation: 241
I had the same issue but it was that I forgot to "Write Changes". I used to work with MSSQL Server but with DB Browser for SQLite even after we run the script we still need to "Write Changes" / Ctrl + S to reflect them in the the database. Also make sure FKs are not null and in the same data type. not int but Integer etc. Also for EDMX you need to define PK in your tables. Weak entities won't be included in EDMX.
Upvotes: 0
Reputation: 53
My issue was when creating the foreign keys I didn't specify NOT NULL. I made the change and the table imported just fine.
Upvotes: 2
Reputation: 2867
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.
Upvotes: 6
Reputation: 1867
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.
Upvotes: 17