This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have this model : (Very simple to start with, in attachment). With this code:
With this error: Id Attribute Source is required My process to create the model was very simple, just drag and drop the table from VS 2012. I know its related to the composite keys/foreign keys, but can't find any clue about how to fix it. Thanks, The code for the Table is: USE [eCommerceHubProdV2.0.1] GO /* Object: Table [dbo].[tblProduct_Attribute_Value] Script Date: 6/10/2013 3:55:36 PM */ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblProductAttributeValue]( [UPC] nvarchar NOT NULL, [IDAttributeDefinition] [int] NOT NULL, [IDAttributeSource] [int] NOT NULL, [IDAttributeValueGUID] [uniqueidentifier] NOT NULL, [CreationDate] [datetime] NOT NULL, [LastUpdate] [datetime] NOT NULL, [LastUpdateBy] nvarchar NOT NULL, CONSTRAINT [PKtblProductAttributeValue] PRIMARY KEY CLUSTERED ( [UPC] ASC, [IDAttributeDefinition] ASC, [IDAttributeSource] ASC )WITH (PADINDEX = OFF, STATISTICSNORECOMPUTE = OFF, IGNOREDUPKEY = OFF, ALLOWROWLOCKS = ON, ALLOWPAGELOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueUPC] DEFAULT (N'') FOR [UPC] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueIDAttributeDefinition] DEFAULT ((0)) FOR [IDAttributeDefinition] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueIDAttributeSource] DEFAULT ((0)) FOR [IDAttributeSource] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueAttributeValueGUID] DEFAULT (newid()) FOR [IDAttributeValue_GUID] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueCreationDate] DEFAULT (getdate()) FOR [CreationDate] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueLastUpdate] DEFAULT (getdate()) FOR [LastUpdate] GO ALTER TABLE [dbo].[tblProductAttributeValue] ADD CONSTRAINT [DFtblProductAttributeValueLastUpdateBy] DEFAULT (N'') FOR [LastUpdateBy] GO ALTER TABLE [dbo].[tblProductAttributeValue] WITH CHECK ADD CONSTRAINT [FKtblProductAttributeValuetblProductAttributeSource] FOREIGN KEY([IDAttributeSource]) REFERENCES [dbo].[tblProductAttributeSource] ([IDAttributeSource]) GO ALTER TABLE [dbo].[tblProductAttributeValue] CHECK CONSTRAINT [FKtblProductAttributeValuetblProductAttributeSource] GO and USE [eCommerceHubProdV2.0.1] GO /* Object: Table [dbo].[tblProduct_Attribute_Source] Script Date: 6/10/2013 3:55:51 PM */ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblProductAttributeSource]( [IDAttributeSource] [int] IDENTITY(1,1) NOT NULL, [Description] nvarchar NOT NULL, [IDAttributeSourceCategory] [int] NOT NULL, [Comment] nvarchar NOT NULL, [Active] [bit] NOT NULL, [CreationDate] [datetime] NOT NULL, [LastUpdate] [datetime] NOT NULL, [LastUpdateBy] nvarchar NOT NULL, CONSTRAINT [PKtblProductAttributeSource] PRIMARY KEY CLUSTERED ( [IDAttributeSource] ASC )WITH (PADINDEX = OFF, STATISTICSNORECOMPUTE = OFF, IGNOREDUPKEY = OFF, ALLOWROWLOCKS = ON, ALLOWPAGELOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceDescription] DEFAULT (N'') FOR [Description] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceIDAttributeSourceCategory] DEFAULT ((0)) FOR [IDAttributeSourceCategory] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceComment] DEFAULT (N'') FOR [Comment] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceActive] DEFAULT ((0)) FOR [Active] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceCreationDate] DEFAULT (getdate()) FOR [CreationDate] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceLastUpdate] DEFAULT (getdate()) FOR [LastUpdate] GO ALTER TABLE [dbo].[tblProductAttributeSource] ADD CONSTRAINT [DFtblProductAttributeSourceLastUpdateBy] DEFAULT (N'') FOR [LastUpdateBy] GO |
|
|
Check that the generated TblProductAttributeValueId is correctly assigning the value you expect to the IdAttributeSource property as that would appear to be set to a default value and is failing the validation check. Also is that field nullable? If so you should remove the required validation on it.
|
|