?
Solved

I add a table into the Entity Framework 4.0, but the table does not show up

Posted on 2010-11-12
14
Medium Priority
?
1,462 Views
Last Modified: 2012-05-10
I created a new table and created the table relationships, just like I have done over a dozen times. But when I add the table in, the .edmx file does not display the new table.

I see a mention of the table name in the .designer.cs file, but it's not at all like the other siccessful ones before it. (See code for sample)

Thenew file is "follow", but the relationships defined in SQL Server are:
FK_follow_to_entity
FK_follow_to_user

Any ideas what could be wrong?

Thanks,
newbieweb
[assembly: EdmRelationshipAttribute("RDDBDEVModel", "FK_comments_to_entity", "Entity", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.Entity), "comment", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.Comment), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel", "FK_comments_to_user", "User", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.User), "comment", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.Comment), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel", "FK_attachment_to_entity", "Entity", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.Entity), "attachment", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.Attachment), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel", "FK_attachment_to_user", "User", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.User), "attachment", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.Attachment), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel", "follow", "Entity", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.Entity), "User", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.User))]

Open in new window

0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34127859
I think that you are going to have to explain how you added the table to the designer.
0
 

Author Comment

by:newbieweb
ID: 34128570
I created the table in the database, like always. I also created the table relationships, the way I have done lots of times. Then I right click the graphical .edmx file and select "Update From Database" or some similar choice on the context menu. I see three tabs, Add, Update, Delete. Under Add I see the new table name, check it, that get it added in. BUT it does not show up graphically the way the tables get added and interconnected, based on the table relastionships defined.

This is the only way I know to add a table. Is there a place where an error would be written, if something failed?

Thanks,
newbieweb
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34129097
Usually, you see the validation errors in the Error List, but there is no guarantee that exceptions will shown in that window.   What happens if you create a new, test .edmx file, and add that table?
0
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

Author Comment

by:newbieweb
ID: 34129467
I will try that on Monday. That's a great idea. I wil let you know.

Thanks.
0
 

Author Comment

by:newbieweb
ID: 34135858
I created a new edmx file and selected Add for all the tables, and once again the Follow table did not appear.  I suspect there is something amiss where the table relationships we have created do not meet the EF4 requirements.

The Follow table has two columns:
entity_id (FK)
user_id (FK)

The table records the associations between the User table and the Entity table. A single user can follow (e.g. track) multiple entities. Multiple user can also follow the same entity.

From a SQL perspective, this works. But I think from an EF4 perspective, perhaps, this is not correct.

What do you think?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34136360
Association tables, for many-to-many relationships, are valid entities for EF4, so I don't know why it isn't adding the table.  When you added that table to the model, did you add the User and the Entity tables also?
0
 

Author Comment

by:newbieweb
ID: 34136549
yes, but I will try creating another trial run of creating another model to be certain.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34137499
Can you show me the XML from the test model, if it doesn't work again?
0
 

Author Comment

by:newbieweb
ID: 34137628
Not sure what you meant by the XML. I tried again and it failed again.

I changed the follow table to following in case it was a reserved word. But that did nothing.

I attached the meta data that shows the relationships defined in the database (shown in my original post) are not used in the metadata.

Let me know how to find the XML.
(RDDBWEB2.Models.user), "project", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.project), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel1", "FK_project_user_requestor", "user", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.user), "project", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.project), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel1", "FK_status_hist_to_status", "status", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(RDDBWEB2.Models.status), "status_history", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.status_history), true)]
[assembly: EdmRelationshipAttribute("RDDBDEVModel1", "following", "entity", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.entity), "user", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.user))]
[assembly: EdmRelationshipAttribute("RDDBDEVModel1", "user_data_admin", "data_admin", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.data_admin), "user", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RDDBWEB2.Models.user))]

Open in new window

0
 

Author Comment

by:newbieweb
ID: 34137648
Also, User and Entity DID show up in both the original edmx and the sample one I just made up.
0
 

Assisted Solution

by:newbieweb
newbieweb earned 0 total points
ID: 34137835
I found this answer:
"If the tables in question implement a many to many relationship between two other entities, and have only two columns, both of which are foreign keys to the other tables, they will be subsumed into the relationship instead of surfaced as separate entities in the model."

Here:
http://efreedom.com/Question/1-1575069/Visual-Studio-Model-Show-New-Tables

I think I should resume testing and see if the table gets updated by EF4.  It sounds like it will.  I will let you know.

Thanks,
newbieweb
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 34138274
To view the XML for the .edmx, you can open the file in an external text editor, or right-click on the .edmx file and use the Open With dialog to select XML (Text) Editor.

 Open With dialog
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 2000 total points
ID: 34138293
Ok, good catch, grasshopper!!  That is a perfect point about the Entity Framework designer--magic is taken care of for you, but you need to understand that it is happening.
0
 

Author Closing Comment

by:newbieweb
ID: 34179035
Thanks. Sometimes a good "old fashioned" Google search does the job:)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question