views:

282

answers:

2

There is a table in a database that i can't change i'm trying to use with Entity Framework. For sake of argument, there is no unique key possible, not even all the columns, all the columns are of type nvarchar(x), and i can't change the database to include a rownumber type column.

Is there any way to get this table into Entity Framework so i can run queries on it? If i need to update it i'll write my own storedproc.

A: 

Can you map a VIEW which returns the table data + an artificial key? Or a stored proc which does the same thing?

Craig Stuntz
+1  A: 

You can create DefiningQuery in the model with Primary Key-column.
For example, it will look for SQL Server in this way:
"select newid() as pk, a.City, a.AddressLine1, a.AddressLine2 from AdventureWorks.Person.Address a" But this entity will be read-only.

Devart