Page 1 of 1

Access Relation

Posted: Fri 27 Jul 2012 09:39
by lc4pro
Hi,

sorry for the second topic but it has nothing to do with my Update Relation topic

So here is a thing.

Code: Select all

CREATE TABLE `data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
);

CREATE TABLE `hit` (
  `data_id` int(11) NOT NULL,
  KEY `fk_hit_data` (`data_id`),
  CONSTRAINT `fk_hit_data` FOREIGN KEY (`data_id`) REFERENCES `data` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
The mapping DataContext shows the correct association between Data and Hit and both classes
have a corresponding navigation property shown in the lqml file but not in the generated vb file. I have no possibility to access the association in code from either side.

What am I doing wrong?

thanks in advance!

Re: Access Relation

Posted: Fri 27 Jul 2012 11:35
by MariiaI
The code for this association is not generated due to the fact that one of the entities does not have the Entity Key ('Hit' in your case). In order to make this association valid, you should mark the 'data_id' property as an Entity Key (it is sufficient to do this in the model only) and re-generate the code.
JIC: in general, in this situation the following warning should have been displayed in Entity Developer:

Code: Select all

Custom tool error: The Type element 'Hit' contains the Association element 'Datum_Hit' but does not have a primary key.  No code will be generated for the association.

Re: Access Relation

Posted: Fri 27 Jul 2012 12:29
by lc4pro
Thanks to help me understand my problem!

I'll add an additional primary key to identify the db entries.

Thanks for help again. Great support! :D