views:

50

answers:

2

I am using VS2010 with C#, and linq-to-sql.

Does anyone have any ideas of where to start looking for a solution?

My database has a 'Cats' table and there is a 'Feet' and 'EyeColour' table that are both linked to it with a one-to-one relationship. The 'Feet' table works fine with linq-to-sql, but 'EyeColour' does not.

I dragged the EyeColour table from the database explorer. It has a one-to-one relationship with another item (Cats) in the database. All properties match 'Feet'.

doing Cat.Feet works, but doing Cat.EyeColour does not, it doesn't appear in the intellisense and gives me a cannot find it error, but both tables are there and the links/relationships are identical.

I tried deleting the designer.cs file so it regenerated, but still nothing. Tried closing/opening VS as well.

Any clues as to what might cause this?

A: 

Look into the .designer.cs file attached to your dbml, and see how the Cat class got generated. It might just be that you have Cat.EyeColour1 instead of Cat.EyeColour, or something like that.

Also, you can try opening your .dbml file with the XML Editor (right click on file -> Open With -> XML Editor), and see if you have the association between Cats and EyeColour - you can compare with what you have for Cats and Feet. It should be something like this:

<Association Name="Category_VideoPlayerFile" Member="Category"
    ThisKey="CategoryId" OtherKey="Id" Type="Category" IsForeignKey="true" />
Dan Dumitru
If that were the case, wouldn't Cat.EyeColour1 show up in the intellisense? Looking through it though I don't see anything like that.
SLC
@SLC - Well, it can be something weirder than EyeColour1, but in normal cases you're right, it should appear in Intellisense. Try looking into your .dbml file for associations...
Dan Dumitru
A: 

Problem solved, turns out there was no primary key on the EyeColour - it was just set to not null unique (which is pretty much the same, but I guess Visual Studio didn't like that).

SLC