Refactor code to support EF, nullable types, and string to Guid conversion