问题描述
|
我正在尝试为具有所有表的chinook数据库创建一个简单的实体模型,而Vs2010没有创建任何关系或导航属性。它们确实存在,它们出现在SSMS的数据库图中。
我有一台没有这个问题的机器(还有vs2010 sp1和sql express 2008 r2),但是我不知道那里有什么不同。
创建的模型如下所示:
解决方法
创建数据库时跳过以下几行。我相信他们会混淆EF:
CREATE UNIQUE INDEX [IPK_Album] ON [dbo].[Album]([AlbumId]);
GO
CREATE UNIQUE INDEX [IPK_Artist] ON [dbo].[Artist]([ArtistId]);
GO
CREATE UNIQUE INDEX [IPK_Customer] ON [dbo].[Customer]([CustomerId]);
GO
CREATE UNIQUE INDEX [IPK_Employee] ON [dbo].[Employee]([EmployeeId]);
GO
CREATE UNIQUE INDEX [IPK_Genre] ON [dbo].[Genre]([GenreId]);
GO
CREATE UNIQUE INDEX [IPK_Invoice] ON [dbo].[Invoice]([InvoiceId]);
GO
CREATE UNIQUE INDEX [IPK_InvoiceLine] ON [dbo].[InvoiceLine]([InvoiceLineId]);
GO
CREATE UNIQUE INDEX [IPK_MediaType] ON [dbo].[MediaType]([MediaTypeId]);
GO
CREATE UNIQUE INDEX [IPK_Playlist] ON [dbo].[Playlist]([PlaylistId]);
GO
CREATE UNIQUE INDEX [IPK_PlaylistTrack] ON [dbo].[PlaylistTrack]([PlaylistId],[TrackId]);
GO
CREATE UNIQUE INDEX [IPK_Track] ON [dbo].[Track]([TrackId]);
GO
, 确保在项目的编译选项中以.NET Framework 4.0为目标。
另外,请确保已选中在模型中包括关系的选项。
此处有更多详细信息
还有一些背景