Print Page | Close Window

Table - View Association

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2307
Printed Date: 29-Jul-2026 at 8:55am


Topic: Table - View Association
Posted By: BillG
Subject: Table - View Association
Date 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?



Replies:
Posted By: kimj
Date 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.



Print Page | Close Window