Hi,
I am trying to create an Entity Framework 4 model based on a legacy SQL server 2008 database. Since the model is going to be published in a web service, I need to omit an integer column called NewsletterSubscribed from one of the model's entities.
After removing the column in the EF designer I got the following compilation error:
Error 59 Error 3023: Problem in mapping fragments starting at line 356:Column Users.NewsletterSubscribed in table Users must be mapped: It has no default value and is not nullable.
C:\Users\Adrian\Documents\Sites\Zeiterfassung\Zeiterfassung\API\V1\EFModel.edmx 357 15 Zeiterfassung
But the column seems to have a default value of 0 bound to it. I tried running this SQL statement against the database:
ALTER TABLE [dbo].[Users] ADD DEFAULT ((0)) FOR [NewsletterSubscribed]
But that also fails:
Msg 1781, Level 16, State 1, Line 3 Column already has a DEFAULT bound to it. Msg 1750, Level 16, State 0, Line 3 Could not create constraint. See previous errors.
So either the column does not have a default value (in which case I am not sure why I can't create one), or Entity Framework doesn't see it. What is going on?
Thanks,
Adrian