开发者

sql bit allow null ef4

开发者 https://www.devze.com 2023-02-19 12:24 出处:网络
I have in my dat开发者_如何学JAVAabase the following table table questions question_id int answerbit nullble

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

0

精彩评论

暂无评论...
验证码 换一张
取 消