Tuesday, September 24, 2013

EF Empty Strings in Non-Nullable Fields

When using Entity Framework, sometimes it is desirable to have non-nullable string fields.  The problem is that if the user leaves the field blank, EF will complain that a value is required in the field.   To fix this, create a metadata class for the entity you are working with.   Then decorate the field with this attribute:
[DisplayFormat(ConvertEmptyStringToNull=false)]
This will allow you to save the entity with an empty string in this field.

Monday, September 23, 2013

Auto entering credentials in Git

Any time you do a Fetch or a Push to a secure Git repository, you will be asked for your username and password.  To have these credentials auto-entered, do the following:


  1. Download got-credential-winstore. https://gitcredentialstore.codeplex.com/
  2. Put it in a folder where you will keep it permanently.
  3. Run it with the -i option to specify the Git location (not 100% sure this step is necessary.
  4. To use this in TortoiseGit, go to Settings/Credentials. 
  5. Select 'wincred - this repository only'