I have following entity class:
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; }
}
When I perform the following:
myDbContext.ProjectUser.ToList()
I get this error:
System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'ProjectUser'
My dbcontext
has the following property:
public virtual DbSet<ProjectUser> ProjectUser { get; set; }
Table script is as following.
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
What's wrong? Class has been generated with scaffolding.
可能是刚刚从User
或Project
模型中的DataAnnotation
命名设置引发的错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.