ok, so I tried creating a new model to test a few things with, and this is what I came up with:
these are the tables I tested with:
Code:
CREATE TABLE t1_guid (
id_t1 char(36) NOT NULL,
PRIMARY KEY (id_t1)
) ENGINE=InnoDB;
CREATE TABLE t2_guid (
id_t2 char(36) NOT NULL,
id_t1 char(36) NOT NULL,
PRIMARY KEY (id_t2),
FOREIGN KEY (id_t1) REFERENCES t1_guid (id_t1)
) ENGINE=InnoDB;
CREATE TABLE t1_int (
id_t1 int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id_t1)
) ENGINE=InnoDB;
CREATE TABLE t2_int (
id_t2 int NOT NULL AUTO_INCREMENT,
id_t1 int NOT NULL,
PRIMARY KEY (id_t2),
FOREIGN KEY (id_t1) REFERENCES t1_int (id_t1)
) ENGINE=InnoDB;
and after generating the model, this is the code that I used:
Code:
testEntities te = new testEntities();
Guid t1guid = Guid.NewGuid();
t1_guid t1 = t1_guid.Createt1_guid(t1guid);
Guid t2guid = Guid.NewGuid();
t2_guid t2_0 = t2_guid.Createt2_guid(t2guid);
t2guid = Guid.NewGuid();
t2_guid t2_1 = t2_guid.Createt2_guid(t2guid);
t2guid = Guid.NewGuid();
t2_guid t2_2 = t2_guid.Createt2_guid(t2guid);
t2guid = Guid.NewGuid();
t2_guid t2_3 = t2_guid.Createt2_guid(t2guid);
t2guid = Guid.NewGuid();
t2_guid t2_4 = t2_guid.Createt2_guid(t2guid);
t1.t2_guids.Add(t2_0);
t1.t2_guids.Add(t2_1);
t1.t2_guids.Add(t2_2);
t1.t2_guids.Add(t2_3);
t1.t2_guids.Add(t2_4);
te.AddTot1_guids(t1);
te.SaveChanges();
and this worked.
but when I tried the following:
Code:
testEntities te = new testEntities();
t1_int t1 = t1_int.Createt1_int(0);
t2_int t2_0 = t2_int.Createt2_int(0);
t2_int t2_1 = t2_int.Createt2_int(0);
t2_int t2_2 = t2_int.Createt2_int(0);
t2_int t2_3 = t2_int.Createt2_int(0);
t2_int t2_4 = t2_int.Createt2_int(0);
t1.t2_ints.Add(t2_0);
t1.t2_ints.Add(t2_1);
t1.t2_ints.Add(t2_2);
t1.t2_ints.Add(t2_3);
t1.t2_ints.Add(t2_4);
te.AddTot1_ints(t1);
te.SaveChanges();
it failed with the error "Object reference not set to an instance of an object."
it seems that it doesn't generate proper ssdl code, or something, and that causes it to fail to get the insert id of the dependent row. if I specify a value for the field the other rows depend on, it works just fine, because it already has it on hand.
has anyone else seen this with the mysql .net connector?