无效的列名Entity Framework Core

时间:2019-03-31 07:49:00

标签: c# entity-framework-core

我有以下实体类:

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

怎么了?类已通过脚手架生成。

1 个答案:

答案 0 :(得分:1)

from sklearn.decomposition import PCA from sklearn.tree import DecisionTreeClassifier from sklearn.datasets import load_iris # load data iris = load_iris() # initiate PCA and classifier pca = PCA() classifier = DecisionTreeClassifier() # transform / fit X_transformed = pca.fit_transform(iris.data) classifier.fit(X_transformed, iris.target) # predict "new" data # (I'm faking it here by using the original data) newdata = iris.data # transform new data using already fitted pca # (don't re-fit the pca) newdata_transformed = pca.transform(newdata) # predict labels using the trained classifier pred_labels = classifier.predict(newdata_transformed) DataAnnotation模型中的User命名设置可能引起了错误。