sql bit allow null ef4
I have in my dat开发者_如何学JAVAabase the following table
table questions
question_id int
answer bit nullble
question string
<Property Name="questionlog_id" Type="int" Nullable="false" oreGeneratedPattern="Identity" />
<Property Name="question_id" Type="int" Nullable="false" />
<Property Name="answer" Type="bit" Nullable="true" />
in the entity framework, when i addObject it automatically set the answer to false (if no value has been given )
questions q = new questions(){
question="blalala"
}
context.Addobject(q);
context.SaveChanges();
q.answer returns False
and error if i try to save it as null
questions q = new questions(){
question="blalala",
answer=null
}
context.Addobject(q);
context.SaveChanges();
returns error
what can i do to set the default value as null
精彩评论