Linq - Relation in .dbml but not in code behind

  • Thread starter Thread starter fredd00
  • Start date Start date
F

fredd00

Hi

I have a db the looks like


DVD - (table)
id (primary key , identity)
title
categoryId (fk on Category Id)
.....

Category (table)
Id (primary key , identity)
name
....

Tag
DvdID (fk on DVD id)
name

when i drop the 3 table on dbml the 3 tables and 2 associations are
created
but when i look at the code behind i only have entyref in category
(EntityRef<DVD>) and DVD (EntityRef<Category>)
why is it that i don't have the relations in Tag(EntityRef<DVD>) and
DVD (EntityRef<Tag>)

the way the code is generated i can't call dvd.Tags even if the
relations is on the dbml

any idea why ?

i even tried with

a relations table
changing

Tag table to
id(primary key, identity)
name

DVDTag (tabl)
DVDId (fk on DVD id)
TagId (fk on TagId)

the table and relations are created on dbml but not EntityRef in code
behind

maybe i'm just approching the tag feature the wrong way

thanks for the help
 
On the designer, select the relationship between DVD (parent) and TAG
(child), and ensure that "Child Property" is true (and is called
Tags). You might also want to check the cardinality (I've assumed
1:many); and also check that the data-types have come over
correctly...

(note that I reproduced just from the designer, so there may be some
subtle differences to your SqlMetal output)

In the dbml, this should be an entry something like (looking at the
DVD_TAG entry) below.

Any help?

Marc

<Table Name="DVD" Member="DVDs">
<Type Name="DVD">
<Column Name="ID" Type="System.Int32" DbType="int"
IsPrimaryKey="true" CanBeNull="false" />
<Column Name="CategoryID" Type="System.Int32" DbType="int"
CanBeNull="false" />
<Association Name="DVD_TAG" Member="Tags" OtherKey="DvdID"
Type="TAG" />
<Association Name="CATEGORY_DVD" Member="Category"
ThisKey="CategoryID" Type="CATEGORY" IsForeignKey="true" />
</Type>
</Table>
 
Back
Top