How to assign default values and define unique keys in Entity Framework 4 Designer
Posted
by csharpnoob
on Stack Overflow
See other posts from Stack Overflow
or by csharpnoob
Published on 2010-04-24T12:37:38Z
Indexed on
2010/04/24
12:43 UTC
Read the original article
Hit count: 335
Hello,
I've had a look at the Entity Framework 4. While generating code for the SQL Server 2008 I came to the point where I want to define some default values for some fields.
how to define in the designer for a Created DateTime Field the DateTime.Now default value?
-> Error 54: Default value (DateTime.Now) is not valid for DateTime. The value must be in the form 'yyyy-MM-dd HH:mm:ss.fffZ'
how to make for code generation a string Field unique. Like E-Mail or Username can exists only once in the table.
I've search alot in the internet and also checked my books Pro Entity Framework 4.0 and Programming Entity Framework. But none of them seems to come up with the default value issue, or using sql commands as default values for database generation.
Another thing is, how to prevent on database generation always from droping tables? Instead i want to append non existing fields and keep the data.
Thanks for any suggestions.
© Stack Overflow or respective owner