简体   繁体   English

实体框架中的任何新列都是空值

[英]Any New Column is Null value in Entity Framework

I am adding a new column to exiting database table with values, but when I used the entity framework model, the column data value return Null, however its has a real value in database.我正在向带有值的退出数据库表添加一个新列,但是当我使用实体框架模型时,列数据值返回 Null,但是它在数据库中具有实际值。

How solve this problem?如何解决这个问题?

If you are using LINQ for data retrieval:如果您使用LINQ进行数据检索:

Double click and open edmx -> right click and select update from database -> select refresh tab and select your table and click ok.双击并打开 edmx -> 右键单击​​并选择从数据库更新 -> 选择刷新选项卡并选择您的表并单击确定。

The above will update your dbcontext file.以上将更新您的 dbcontext 文件。

在此处输入图片说明

在此处输入图片说明

If you are using stored procedure, you will have to update the complex type of your stored procedure如果您使用的是存储过程,则必须更新存储过程的复杂类型

The most likely explanation for your problem is that you did not COMMIT the changes you made to the database.对您的问题最可能的解释是您没有提交对数据库所做的更改。 Not the changes to the schema but the table updates.不是对架构的更改,而是表更新。 EF is returning NULL values because you did not commit your changes so the actual field values are ... NULL ! EF 返回 NULL 值,因为您没有提交更改,因此实际字段值是 ... NULL !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM