列 ID 在规范中出现多次?
在将 EF 4.1 代码优先方法与 Sql Compact 4 一起使用时,我收到此错误消息。我没有看到任何模型的 id 列超过一个,所以我不知道为什么会发生此错误。什么可能导致此错误?
编辑:我想指定一些额外的事情。数据库创建成功,但模型创建不成功。并且 sqlce 方法已引发异常。
I am getting this error message when using EF 4.1 code first approach with Sql compact 4. I don't see any model who has id column more than one so i have no idea why this error occured. What can cause this error ?
Edit : I want to specifiy few extra things. Database creating is success but model creating is not. And Exception has been thrown from sqlce methods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此问题源于返回两个或多个具有相同名称的列的 SQL 查询。 SQL 可以毫无问题地处理列上的精确重复名称,但 C# 会像这样到处抛出错误。
示例情况:
Id 和 Name 列将重复并导致 EF 异常
This issue stems from a SQL query that returns two or more columns that have an identical name. SQL will handle exact duplicate names on columns with no problem but c# will puke errors all over like this one.
example situation:
The Id and Name columns would be duplicated and cause an exception with EF
当迁移代码未更新到最新时也可能导致这种情况。当多次执行 Add-Mirgration 时,通常会发生这种情况。改为运行以下命令:
This could also be caused when the migration code is not update to date. This usally occurs when the executing the Add-Mirgration muliple times. Run the following command instead: