I'm trying to "Entitify" some external table (which I don't administer) in order to use it within a MVC application and in principle I'm not being terribly successful with the attempt (VS2008 output):
Error List [0 Errors] [0 Warnings] [1 Message]
Description
The table/view 'DATABASE.dbo.table' 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.
File
C:\Documents and Settings\%USERNAME%\My Documents\Visual Studio 2008\Projects\MVC_Entity_Test\MVC_Entity_Test\Models\EmployeesDataModel.edmx
Line
0
Column
1
Project
MVC_Entity_Test
Output
Show output from: Entity Data Model
Added the connection string to Web.Config.
Successfully registered the assembly 'System.Data.Entity, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' in Web.Config.
The model was generated with warnings or errors.
Please see the Error List for more details. These issues must be fixed before
running your application.
Loading metadata from database took 00:00:06.2809306.
Generating model took 00:00:03.0359078.
Writing out the EDMX file took 00:00:00.0230083.
Added the connection string to Web.Config.
Successfully registered the assembly 'System.Data.Entity, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' in Web.Config.
The model was generated with warnings or errors.
Please see the Error List for more details. These issues must be fixed before running
your application.
Loading metadata from database took 00:00:12.3208290.
Generating model took 00:00:03.6914563.
Writing out the EDMX file took 00:00:02.1670689.
So my question would be, is it absolutely mandatory to declare a PK on the source table to correctly map it as an ASP.NET Entity?
Any advice will be greatly appreciated.
Note: I wouldn't like this thread to become a dissertation about great, standard-driven, academically-backed database modeling, thing is, I have to deal with this external table that comes from a view somewhere, that comes from a table somewhere, so on so so forth, so I don't really have any control over it. The point being that I just want to get my side of the thing done.