View entity key as navigation property

I have a table

CREATE TABLE Tasks
( 
    ID INT IDENTITY(1,1) NOT NULL CONSTRAINT PRIMARY KEY PkTasks,
    ...other fields...
)

      

and view

CREATE VIEW VTaskInfo
AS
SELECT
    T.ID IDTask,
    ...other fields...
FROM
    Tasks T

      

How do I create a navigation property that links the Task and VTaskoInfo objects? Usually, defining navigation properties requires removing the id property, but this timing property is the primary key and cannot be removed. I can change the definition of VTaskInfo to

CREATE VIEW VTaskInfo
AS
SELECT
    T.ID IDTask,
    T.ID ID,
    ...other fields...
FROM 
    Tasks T

      

and specify id as entity key and IDTask as navigation property, but I don't like that. Is there something else I can do?

How do you render views in EF?

+2


source to share


1 answer


Here's an article on using EF and DB Views:



http://smehrozalam.wordpress.com/2009/08/12/entity-framework-creating-a-model-using-views-instead-of-tables/

0


source







All Articles