views:

1234

answers:

2

Is it possible to assign a blank string (i.e. "") as a Default Value in the Entity Framework's EDMX designer? The only technique I've found is to edit the edmx file manually using a text editor

+1  A: 

Yes, the only way that I've found to set an empty string as the default value is to edit the EDMX. Editing the designer file doesn't work as the code is regenerated.

This is really a bug in the entity framework that needs to be addressed.

EDIT: Actually, setting an empty string in XML is quite painful so it might be easier to just set the value to string.Empty in the application when creating a new entity.

Damien
A: 

What I did was to create a default constructor in a partial class where I set

_privateFieldName = string.Empty;

The partial class obviously would be in a different file and won't get regenerated by the designer. The only downside to this method is that now any changes to the default value in the designer will not apply

Davy8
Davy8, mind elaborating with some code?
Nate