Access Relation

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Access Relation

Post by lc4pro » Fri 27 Jul 2012 09:39

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!

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Access Relation

Post by MariiaI » Fri 27 Jul 2012 11:35

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.

lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Re: Access Relation

Post by lc4pro » Fri 27 Jul 2012 12:29

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

Post Reply