Friday, November 13, 2015

Default boolean value in Entity Framework

To set a default value to bit column in EF edit the migration file manaully and add defaultvaluesql parameter like

AddColumn("Jobs", "IsAdvertisingRequired", c => c.Boolean(nullable: false, defaultValueSql: "0"));
 
 Reference: http://stackoverflow.com/questions/5567567/default-bool-to-false-when-null-in-database-with-entity-framework-4-1-code-first

No comments:

Regex obfuscate email

 Use this code in C# to obfuscate email using regex // Online C# Editor for free // Write, Edit and Run your C# code using C# Online Compile...