New Posts New Posts RSS Feed: Table - View Association
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Table - View Association

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Table - View Association
    Posted: 15-Nov-2010 at 10:03am

I need the ability to navigate from a table to a view. for example I have a table called Event that hold all the calls coming into a center. I have a view called EventFirstStep which holds only the first step of the event which will tell me the issue of the call. In my Event class I want to do the following:

 
public string EventIssue
{
      get{
             return this.EventFirstStep.Detail;
      }
}
 
In my EDMX I created an association between the EventFirstStep view and the Event Table. In my Event class I created the above code and it compiles fine.
 
When I run the program I get the following error.
 
Error 1 #error: 'DevForce requires that foreign key columns be included in the model. This must be set when the EDMX is first created. If you are upgrading from DevForce 2009, you cannot use the old model and should recreate it using the Entity Framework for .NET 4.0.  The following associations were not set up with foreign key associations enabled: EventFirstStepEvent' 
 
What do I need to do in addition to creating the association to make this work?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 15-Nov-2010 at 6:59pm
First make sure that the storage model definition of the EntityKey for the view-backed entity is correct.  When a view is included in the EDMX the designer will try to infer an EntityKey and the inference isn't always correct.  Next, when you add the association to the conceptual model, don't check the "Add foreign key properties" check box in the dialog, since presumably there's some sort of "EventId" column on the view that will point it back to the Event table.  After creating the association, double click the association in the designer to bring up the Referential Constraint window (there's probably some other way of getting to this information, but I don't know it), and there set the principal and dependent "key" properties.  That should be all that's needed.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down