public static string ToDbType(Type type, ICustomAttributeProvider attributes) { var canBeNull = !type.IsValueType && !attributes.Any<RequiredAttribute>(); return MapType(type, attributes, ref canBeNull) + (canBeNull ? string.Empty : " not null"); }