I am using EF4 and trying to add a SQL view into the model.
The relationship between them is 1-1, one side is Order the other is OrderSummary (the summary is the view and contains aggregate data).
When I add the view it detects the key on the view (OrderID) but I have to manually create the 1-1 relationship.
The problem I am encountering though is that when I try and build the application I get the error:
No mapping specified for the following EntitySet/AssociationSet - OrderOrderSummary.
I've been hunting around and can't find a solution to this particular problem when using a view, most of the errors seem to be around incorrectly configured database schema but so far as I can tell my view is ok:
CREATE VIEW [store].[OrderSummary]
AS
SELECT store.Orders.OrderID, COUNT(*) AS LineCount
FROM store.Orders INNER JOIN
store.OrderLines ON store.Orders.OrderID = store.OrderLines.OrderID
GROUP BY store.Orders.OrderID, store.OrderLines.OrderLineID
Do I need to do anything more to my view for it to work in EF and in a 1:1 relationship?
I solved this problem. It appears when I was creating the association I wasn't specifying the referential constraint (by double clicking the line between the table/view).
Took a little while but hopefully my pain can help someone else!