小编Jes*_*ios的帖子

部分类中的自定义属性(无效的列名)

我通过脚本创建了我的数据库,然后使用 scaffold 命令在 Visual Studio 中创建了我的类,我为实体(用户)添加了一个新的部分类,每当我运行时,我在其中添加了一些自定义属性(这不会​​在数据库中)获取到此实体,它会为我在分部类中设置的每个自定义属性抛出错误无效的列名。

异常消息: SqlException:无效的列名“ResidentialName”。无效的列名“UserDocumentCount”。无效的列名“UserPaymentCount”。

从数据库创建的分部类。

public partial class User
    {
        public User()
        {
            UserDocument = new HashSet<UserDocument>();
            UserPayment = new HashSet<UserPayment>();
        }

        public int UserId { get; set; }
        public string UserIdentityId { get; set; }
        public int? ResidentialId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public string Telephone { get; set; }
        public string Street { get; …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio entity-framework-core asp.net-core

3
推荐指数
1
解决办法
855
查看次数