映射后列名无效 [英] Invalid column name after mapping

查看:196
本文介绍了映射后列名无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的一个表中添加了一个(bit\bool)列 IsController

I have added a (bit\bool) column IsController to one of my tables

ALTER TABLE P_USER ADD IsController bit NOT NULL DEFAULT 0

更新了edmx和将 IsController 添加到 MY_USER 实体,然后将其名称更改为
IsControllerX 并将其映射到表中的 IsController

Updated the edmx and added IsController to the MY_USER entity, then changed its name to IsControllerX and mapped it to the IsController from the table.

并将其设置在解决方案中.domain.business cs文件:

And set this inside the solution.domain.business cs file:

   public virtual bool IsControllerX { get; set; }

在调试时我有错误:

执行命令定义时发生错误。有关详细信息,请参阅
内部异常。 InnerException:无效的列名称
'IsController'。

An error occurred while executing the command definition. See the inner exception for details. InnerException: Invalid column name 'IsController'.

错误是与 IsController 而不是与 IsControllerX !这是我映射到的列的名称 - 数据库中列的名称!

The error is with the IsController and not with IsControllerX! That is the name of the column that I mapped to - the name of the column inside the database!

有人可以解释为什么我得到这个错误?

Can someone please explain why I get this error?

推荐答案

如何更新您的模型和生成的类?

HOW did you update your model and your generated classes??

在EDMX中,您应该选择更新模型从上下文菜单中的数据库选项,然后在更新向导中,您应该选择已修改的表:

In the EDMX, you should select the Update Model From Database option from the context menu, and then in the Update Wizard, you should pick your table that has been modified:

这样做会正确更新您的EDMX和它在我的场景中工作得很好。你这样做了,还是失败了?或者你只是手动执行?

Doing this will properly update your EDMX and it works just fine in my scenario. Did you do it this way, and it still fails?? Or did you just do it manually ??

这篇关于映射后列名无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆