score:1

actually, after posting my comment i had a bit of a brainwave, which might end up answering your question. this is a theory:

you mentioned your table is defined as follows:

create table groups(
   manhom int primary key,
   tennhom char(100)
);

that yields an entity, correctly decorated with [key] attribute:

public partial class group
    {
        [key]
        public int manhom { get; set; }
        public string tennhom { get; set; }
    }
}

what i suspect happens when you call ef's .savechanges() is it completely ignores the value id manhom assuming that the db will take care of it. in mysql however, the pk will not auto-increment unless you tell it to. which is where you need to either:

1. update table:

create table groups(
   manhom int auto_increment primary key,
   tennhom char(100)
);

2. update model:

this so answer provides some guidance:

public partial class group
    {
        [key]
        [databasegenerated(databasegeneratedoption.none)]
        public int manhom { get; set; }
        public string tennhom { get; set; }
    }
}

Related Query

More Query from same tag