Description:
.Net Connectors: 6.9.8
.Net Entity Framework: 6.1.3
language: C#
update-database -script results in binary (without a length parameter) and also update-database to create a new database on MySql results in a field binary(1)
expected beahvior: create binary(10)
error: It seems as if the MaxLength attribute is not used
1. POCO:
public class User
{
[Key]
[Column("Id")]
public int Id { get; set; }
[Required, MaxLength(10)]
[Column("Password", TypeName = "binary")]
public byte[] Password { get; set; }
}
2. using add-migration in package manager gives me the migration class
CreateTable(
"dbo.Users",
c => new
{
Id = c.Int(nullable: false, identity: true),
Password = c.Binary(nullable: false, maxLength: 10, fixedLength: true, storeType: "binary"),
})
.PrimaryKey(t => t.Id);
3. update-database -script returns
create table `Users` (`Id` int not null auto_increment,`Password` binary not null, primary key ( `Id`) ) engine=InnoDb auto_increment=0
I expected:
create table `Users` (`Id` int not null auto_increment,`Password` binary(10) not null, primary key ( `Id`) ) engine=InnoDb auto_increment=0
How to repeat:
create a new project and add code first entity with the above mentioned class and a context including this class e.g.:
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class MySqlContext : DbContext
{
static MySqlContext()
{
Database.SetInitializer<TradingDataContext>(null);
}
public MySqlContext()
: base("Name=MySqlContext")
{
}
public MySqlContext(string connectionString)
: base(connectionString)
{
}
public DbSet<User> Users { get; set; }
}
run enable-migrations
added in configuration.cs:
SetSqlGenerator("MySql.Data.MySqlClient.EF6", new MySql.Data.Entity.MySqlMigrationSqlGenerator());
run add-migration in package manager (I'm using Visual Studio)
run update-database -script (to see the sql code)
run update-database (to verify this error on the database)
Suggested fix:
my first guess: as in https://dev.mysql.com/doc/relnotes/connector-net/en/connector-net-news-6-5-5.html this was a bug for: Missing length specifier for data types, such as VARBINARY instead of VARBINARY(n).
Description: .Net Connectors: 6.9.8 .Net Entity Framework: 6.1.3 language: C# update-database -script results in binary (without a length parameter) and also update-database to create a new database on MySql results in a field binary(1) expected beahvior: create binary(10) error: It seems as if the MaxLength attribute is not used 1. POCO: public class User { [Key] [Column("Id")] public int Id { get; set; } [Required, MaxLength(10)] [Column("Password", TypeName = "binary")] public byte[] Password { get; set; } } 2. using add-migration in package manager gives me the migration class CreateTable( "dbo.Users", c => new { Id = c.Int(nullable: false, identity: true), Password = c.Binary(nullable: false, maxLength: 10, fixedLength: true, storeType: "binary"), }) .PrimaryKey(t => t.Id); 3. update-database -script returns create table `Users` (`Id` int not null auto_increment,`Password` binary not null, primary key ( `Id`) ) engine=InnoDb auto_increment=0 I expected: create table `Users` (`Id` int not null auto_increment,`Password` binary(10) not null, primary key ( `Id`) ) engine=InnoDb auto_increment=0 How to repeat: create a new project and add code first entity with the above mentioned class and a context including this class e.g.: [DbConfigurationType(typeof(MySqlEFConfiguration))] public class MySqlContext : DbContext { static MySqlContext() { Database.SetInitializer<TradingDataContext>(null); } public MySqlContext() : base("Name=MySqlContext") { } public MySqlContext(string connectionString) : base(connectionString) { } public DbSet<User> Users { get; set; } } run enable-migrations added in configuration.cs: SetSqlGenerator("MySql.Data.MySqlClient.EF6", new MySql.Data.Entity.MySqlMigrationSqlGenerator()); run add-migration in package manager (I'm using Visual Studio) run update-database -script (to see the sql code) run update-database (to verify this error on the database) Suggested fix: my first guess: as in https://dev.mysql.com/doc/relnotes/connector-net/en/connector-net-news-6-5-5.html this was a bug for: Missing length specifier for data types, such as VARBINARY instead of VARBINARY(n).