diff --git a/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs b/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs index 35a1a843c..6b7d97f34 100644 --- a/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs +++ b/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs @@ -315,20 +315,26 @@ private static string FilterClrDefaults(string dataTypeName, bool nullable, stri private string CreateDefaultValueString(string defaultValue, string dataType) { + if (defaultValue == null) + { + return null; + } + // Pending the MySqlConnector implement MySqlCommandBuilder class if (string.Equals(dataType, "timestamp", StringComparison.OrdinalIgnoreCase) && string.Equals(defaultValue, "CURRENT_TIMESTAMP", StringComparison.OrdinalIgnoreCase)) { return defaultValue; } - else if (defaultValue != null) - { - return "'" + defaultValue.Replace(@"\", @"\\").Replace("'", "''") + "'"; - } - else + + // Handle bit values. + if (string.Equals(dataType, "bit", StringComparison.OrdinalIgnoreCase) + && defaultValue.StartsWith("b'")) { - return null; + return defaultValue; } + + return "'" + defaultValue.Replace(@"\", @"\\").Replace("'", "''") + "'"; } private const string GetPrimaryQuery = @"SELECT `INDEX_NAME`,