views:

252

answers:

1

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?

A: 

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/

UpTheCreek
I saw this article. It doesn't solve my question.
LukLed

related questions