Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ to SQL Associations Not Generating
    primarykey
    data
    text
    <p>I created a basic database via SQL Server, with the tables generated by the following code:</p> <pre><code>CREATE TABLE [dbo].[Characters] ( [ID] INT NOT NULL PRIMARY KEY, [Name] varchar(MAX) NOT NULL, [RefName] varchar(8) NOT NULL ) CREATE TABLE [dbo].[Players] ( [ID] INT NOT NULL PRIMARY KEY, [Name] VARCHAR(MAX) NOT NULL, [SkypeHandle] VARCHAR(MAX) NOT NULL ) CREATE TABLE [dbo].[CharacterOwnership] ( [CharacterID] int NOT NULL, [PlayerID] int NOT NULL, CONSTRAINT [FK_CharacterOwnership_ToCharacters] FOREIGN KEY ([CharacterID]) REFERENCES [Characters]([ID]), CONSTRAINT [FK_CharacterOwnership_ToPlayers] FOREIGN KEY ([PlayerID]) REFERENCES [Players]([ID]), ) </code></pre> <p>Dragging the tables over from Server Explorer in Visual Studio 2012, I generated the following diagram:</p> <p><img src="https://i.stack.imgur.com/8RBOy.png" alt="Automatically Generated ERD"></p> <p>As far as I can tell, I set up the primary keys and foreign keys correctly. </p> <p>With</p> <pre><code>var db = new DBClassesDataContext(); </code></pre> <p>LINQ is able to access every table, and any field of that table without issue. However it <em>cannot</em> bring up associated tables.</p> <p>I have setup another project with LINQ to SQL (with another database) in the past few days and didn't have this issue before. Googling around everyone else who has had this issue that I can find had it because the PKs and FKs were not correctly configured, however as before stated they <em>appear</em> correct to me. (If they're not, feel free to point out the error of my ways!)</p> <p>I have also followed advice saying to close Visual Studio and reopen, but to no avail.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload