I am using the entity framework for getting data from database. I recently added a new column in database and updated the EDMX model from database. In the EDMX model I can see the new field. But when I retrieve the data from database, this newly added field is always set to false. I have verified in the DB that some of the rows for this column are set to true.
Asked
Active
Viewed 1,783 times
1 Answers
1
False is the default value for boolean. If you're accessing the right database and you're sure about the values, you must be omitting the bit column in the select statement, so when you get the values, you see just the default value for the bit field.

walther
- 13,466
- 5
- 41
- 67
-
I am accessing the correct database, I have verified that part. Since i am using entity framework there is no scope for ommiting any column. – SharpCoder Mar 04 '15 at 12:22
-
@SharpCoder, of course there's a way of omitting that. You still have to construct the SQL queries, explicitly or implicitly, but you have to. Also you might be missing relation to the database for that column... If everything is right, there's no way it would behave like you're describing. – walther Mar 04 '15 at 12:24
-
I just added a new column of type nvarchar(255). Added some data to it. Now when i try to access the column, the value is null. Obviously, I am making some mistake but its hard to understand. As far as i know, we do not explicitly say get me these columns, Entity framework fetchs all the columns by default – SharpCoder Mar 04 '15 at 12:33
-
@SharpCoder, can you show your code and the process you went through? – walther Mar 04 '15 at 13:05
-
I am experiencing this same issue but with EF core. One interesting thing about my problem is that when I try to access a record that was added on the same execution instance, the column would show false. If I stopped the instance and restarted it, it would then show the correct value (true). – jorge cordero Jul 07 '22 at 21:35