Unable to cast object of type 'System.String' to type 'System.Int32'.

原因 数据库中 code 字段 类型为 varchar 而实体的类型为 int  导致string 类型无法转化为int 类型而报错

        public int code { get; set; }

 参考:https://www.cnblogs.com/Godric/p/10111594.html

转载于:https://www.cnblogs.com/mlh1421/p/11603606.html