我有以下实体类:
public partial class ProjectUser
{
public int Id { get; set; }
public int ProjectId { get; set; }
public int UserId { get; set; }
public virtual Project Project { get; set; }
public virtual Users User { get; set; }
}
当我执行以下操作时:
myDbContext.ProjectUser.ToList()
我收到此错误:
System.Data.SqlClient.SqlException (0x80131904): 列名称“ProjectUser”无效
我dbcontext的具有以下属性:
public virtual DbSet<ProjectUser> ProjectUser { get; set; }
表格脚本如下。
CREATE TABLE [dbo].[ProjectUser]
(
[Id] [int] IDENTITY(1,1) NOT NULL,
[ProjectId] [int] NOT NULL,
[UserId] [int] NOT NULL,
CONSTRAINT [PK_ProjectUser]
PRIMARY KEY CLUSTERED ([Id] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
怎么了?已使用脚手架生成类。
ITMISS
相关分类