日期:2014-05-20 浏览次数:20873 次
CREATE TABLE [dbo].[User] ( [ID] int IDENTITY(1,1) NOT NULL, [Name] nvarchar(max) NOT NULL, [Blog_ID] int NOT NULL ); GO -- Creating table 'Blog' CREATE TABLE [dbo].[Blog] ( [ID] int IDENTITY(1,1) NOT NULL, [Name] nvarchar(max) NOT NULL, [UserId] int NOT NULL ); GO -- Creating table 'Post' CREATE TABLE [dbo].[Post] ( [ID] int IDENTITY(1,1) NOT NULL, [Title] nvarchar(max) NOT NULL, [Content] nvarchar(max) NOT NULL, [BlogId] int NOT NULL, [Blog_ID] int NOT NULL ); GO -- Creating table 'Comment' CREATE TABLE [dbo].[Comment] ( [ID] int IDENTITY(1,1) NOT NULL, [Title] nvarchar(max) NOT NULL, [Content] nvarchar(max) NOT NULL, [PostId] int NOT NULL, [Post_ID] int NOT NULL ); GO
[ForeignKey("tid")] public AdDisplayType DisplayType { get; set; } public int tid { get; set; }
------解决方案--------------------
你还记得你建立这个东西的时候,那个向导页不, 下面有小的选项框“在模型中加入外键列”,你勾选的他,自然EF就生成了他,这是你自己选择滴。咋又怪到EF头上了