问题与实体框架加列数据库表后, [英] Problem with Entity Framework after adding column to DB table

查看:256
本文介绍了问题与实体框架加列数据库表后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个新的nvarchar列在我的数据库添加到表中。所以我加了列,然后发射了Visual Studio的更新EDMX文件的实体框架。

I needed to add a new NVARCHAR column to a table in my DB. So I added the column, and then fired up Visual Studio to update the EDMX-file for the Entity Framework.

我跑从数据库上的一切更新模型,这不仅造成数据读取器不兼容-errors。所以我改名为整个表在数据库中,从数据库中更新EDMX,改名为表回原来的名字,又跑到更新,然后创造了新的功能,进口所有受影响的存储过程。但我仍然得到同样的错误:

I ran update model from database on everything, which only resulted in "data reader is incompatible"-errors. So I renamed the whole table in the DB, updated EDMX from database, renamed the table back to the original name, ran update again, and then created new function imports for all affected stored procedures. But I still get the same error:

数据读取器不兼容
  指定的[产品型号] [实体]。一个
  的类型的部件,
  '[列]',不具有
  在数据相应柱
  读者使用相同的名称。

The data reader is incompatible with the specified '[Model].[Entity]'. A member of the type, '[Column]', does not have a corresponding column in the data reader with the same name.

我四处张望了一下,这似乎是一个常见的​​错误,如果列名是在数据库和框架不同。但是,这是不是这种情况,它们具有相同的名称

I've looked around a bit, and this seems to be a common error if the column name is different in the database and framework. This is however not the case, they have the same name.

我可以通过[实体] .Context的code访问列。[专栏],所以我不太明白,数据读取器抱怨。

I can access the column in the code via [Entity].Context.[Column], so I don't quite see what the data reader is complaining about.

我已经江郎才尽,所以任何帮助的欢迎。

I've run out of ideas, so any help welcome.

推荐答案

原来,EDMX是好的,但设计师,一些奇怪的原因,停止了更新Designer.cs在我的项目。

Turns out the EDMX was fine, but the designer has, for some odd reason, stopped update Designer.cs in my project.

不得不去并手动编辑它。

Had to go in and manually edit it.

这篇关于问题与实体框架加列数据库表后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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