开发者

Entity key of a view as navigation property

I have a table

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

and a view

CREATE VIEW VTaskInfo
AS
SELECT
 开发者_运维技巧   T.ID IDTask,
    ...other fields...
FROM
    Tasks T

How can I create navigation property connecting 'Task' and 'VTaskoInfo' entities? Usually defining navigation properties requires deleting id property, but this time property is primary key and can't be deleted. I could change VTaskInfo definition 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 this solution. Is there something else I can do?

How do you map views in EF?


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜