I've just started using LLBLGen Pro (and I like it a lot), and I have what's probably a real newbie question (I looked and couldn't find the answer in the documentation or on the forum):
I'm using the Self Servicing, two class scenario with the 3/31/06 version of LLBLGen Pro with VisualStudio 2005 and SQL Server 2005.
I have an entity named Company which is a sub-type of the entity Party. In both Party and Company the primary key consists of two fields, Id and Version. (in Company I named these IdCompany and VersionCompany). I have defined a Foreign Key relationship FK_Party_Company_Party that matches Id with IdCompany and Version with VersionCompany. I think this is all set up correctly because LLBLGen Pro recognizes the sub-type relationship between these entities.
Both Id and IdCompany have SQLServer properties Identity=True, Identity seed=1, Identity increment=1
It's easy to create a PartyEntity:
PartyEntity party = new PartyEntity();
party.Version = 1;
party.Save();
But when I try to create a CompanyEntity:
CompanyEntity company = new CompanyEntity();
company.Version = 1;
company.VersionCompany = 1;
company.Save();
I get an exception: An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Party_Company_Party". The conflict occurred in database "Test1", table "dbo.Party". The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
I used SQL Server Profiler to see the SQL that was being executed when I tried to save a CompanyEntity:
declare @p3 int
set @p3=26
exec sp_executesql N'INSERT INTO [dbo].[Party] ([Version]) VALUES (@Version);SELECT @Id=SCOPE_IDENTITY()',N'@Id int output,@Version
smallint',@Id=@p3 output,@Version=1
select @p3
declare @p3 int
set @p3=NULL
exec sp_executesql N'INSERT INTO [dbo].[Company] ([VersionCompany]) VALUES (@VersionCompany);SELECT
@IdCompany=SCOPE_IDENTITY()',N'@IdCompany int output,@VersionCompany smallint',@IdCompany=@p3 output,@VersionCompany=1
select @p3
What is it that I need to do to create a CompanyEntity?
Thank you!
Wayne