views:

35

answers:

1

The .NET Entity framework is giving me the following error:

"The table/view 'Foo.dbo.vwFoo' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity you will need to review your schema, add the correct keys and uncomment it."

The view is a collection of a variety of tables and calculations. What I'd like to do is create a "logical key" using one of the columns that I know should be unique. I can't figure out how to do this in SQL Server Manager 2005 (not a DBA.)

Anyone know how I could accomplish this?

+3  A: 

The EF can't find the PK, because VIEWs don't have PKs. However, if the view returns a unique column, you can tell the EF that this is the "PK."

It's explained in this tip: How to work with Updatable Views

Craig Stuntz