3
votes

When I want to connect to MySQL by Entity framework (code first) I get this error:

(22,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Byte[Nullable=False,DefaultValue=]' of member 'Permission' in type 'News.Models.Author' is not compatible with 'MySql.tinyint[Nullable=False,DefaultValue=]' of member 'Permission' in type 'CodeFirstDatabaseSchema.Author'.

The name of colum in db is Permission with tinyint datatype. and the below is my class.

   public class Author
    {
     ...
     public byte Permission { get; set; }
     ...
    }
3

3 Answers

2
votes

It's fixed in Connector/Net 6.4.5 which is not out yet.

http://bugs.mysql.com/bug.php?id=62135

0
votes

According to this table, you should be using sbyte as Author.Permission type.

0
votes

Are you explicitly mapping it using the Fluent API or something? Because I just ran code and when EF Code First generated my database tables, it used tinyint automatically.

Edit: I did it again with the following Fluent API mapping and it still worked perfectly.

mb.Entity<TestObject>()
  .Property(u => u.test)
  .HasColumnType("tinyint");

public class TestObject
{
  public long ID { get; set; }
  public byte test { get; set; }
}