OK, here's a list of the steps to reproduce - just to be sure I started from scratch...
Environment:
Windows XP SP2
SQL Server 2005 (RTM)
LLBLGen v1.0.2005.1 (November 18th)
-
Create new database called LLBLGenSample
-
Create new tables as follows:
CREATE TABLE [dbo].[Campaign](
[ID] [int] NOT NULL,
[CampaignTypeID] [int] NOT NULL,
[Discriminator] char COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Name] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Location] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_Campaign] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[CampaignType](
[ID] [int] NOT NULL,
[Discriminator] char COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Name] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] varchar COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_CampaignType] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
No relationships are defined between the tables.
- Create views to create the entities from, the views are:
CREATE VIEW [dbo].[CampaignDC]
AS
SELECT ID, CampaignTypeID, Discriminator, Name, Description, Location
FROM dbo.Campaign
CREATE VIEW [dbo].[CampaignTypeDC]
AS
SELECT ID, Discriminator, Name, Description
FROM dbo.CampaignType
-
Create a new LLBLGen project
-
Point to the database and retreive the schema for views and stored procedures (I used trusted security).
-
Create entities based on the views:
* CampaignEntity based on view CampaignDC
* CampaignTypeEntity based on view CampaignTypeDC
-
Set the 'ID' atttribute in each entity to be 'part of the primary key' (this maps to the ID column in the DB which is the PK)
-
Create a new subtype from Campaign, called Event and set the discrimintor column:
Campaign - C
Event - E
-
Create a new subtype from CampaignType called EventType and set the discriminator column:
CampaignType - C
EventType - E
-
Add a new m:1 relationship between Event and EventType where Event.CampaignTypeID is mapped to EventType.ID
-
Without changing the database schema, choose refresh catalog and the relationship between the sub classes will be removed.
Cheers,
Stef