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.
Probably the error just raised from DataAnnotation naming settings in User or Project models.
 NaDeR Star
 NaDeR StarUser contributions licensed under CC BY-SA 3.0