2

I have used Entity Framework 6.1.3 [DBContext] Database first approach in MVC application. I have a table with default constrains in a column[ex: default value 20].

When adding new record via stored procedure without the mentioned value of default constrain column, it's working fine[ new entry added into table with default value colum=20].

But when I try to add records via entity framework, it throws exception due to default constrain not being defined in EDMX [the default column value initialized as null, it's not manually defined in object before being added to context].

Can you suggest default constrain will support it in entity framework 6.0? And can you provide a solution to add default constrain value to table when you add record via EDMX?

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
Anandh_Techie
  • 109
  • 1
  • 7
  • You could create a partial class and then set the value in the constructor. http://stackoverflow.com/questions/12691854/setting-default-value-in-entity-framework-database-first – Steve Greene Aug 14 '15 at 17:39

1 Answers1

1

Unfortunately default value constraints are not supported by Entity Framework 6.0. They're reportedly coming in Entity Framework 7, though, and Entity Framework 7.0.0-beta6 is available now.

MikeTV
  • 645
  • 6
  • 14