O'Reilly Forums: Parent/ Child Relationship On Same Entity - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Parent/ Child Relationship On Same Entity How to create a parent / child relationship to same entity

#1 User is offline   saintperez 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 28-February 11

Posted 28 February 2011 - 08:22 PM

I have a Category entity mapped to a table in SQLServer of the same name.

CREATE TABLE [dbo].[VendorCategory](

[VendorCategoryID] [int] IDENTITY(1,1) NOT NULL,

[VendorID] [int] NOT NULL,

[VendorCategoryName] [nvarchar](50) NOT NULL,

[VendorCategoryDescription] [nvarchar](max) NULL,

[VendorParentCategoryID] [int] NULL,

[DateCreated] [datetime] NULL





Now I'm trying to create a Parent / Child relationship on this entity object to itself. Problem I'm having is that when I go to the mapping details for this association I select my table VendorCategory then I am presented with two rows for mapping navigation.

The first one I can map to the VendorCategoryID field to VendorParentCategoryID field. But on the second row I cannot map from VendorParentCategory to VendorCAtegoryID. WHen I try to build the library I get the following:

Error 1 Error 2027: If some of the EntitySet or the AssociationSet mapped to the same store EntitySet, and one of the sets includes a function mapping, all related entity and AssociationSets in the EntityContainer must also define function mappings. The following sets require function mappings: VendorCategoryVendorCategory.
C:\Projects\micsan\MicsanWebSite\SpikeTek\SpikeTek.NOP.Data\Model\NOPModel.edmx
510 11 SpikeTek.NOP.Data

Thanks,
Santiago

0

#2 User is offline   marilynbrown 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 06-February 12

Posted 06 February 2012 - 06:56 AM

View Postsaintperez, on 28 February 2011 - 08:22 PM, said:

I have a Category entity mapped to a table in SQLServer of the same name.

CREATE TABLE [dbo].[VendorCategory](

[VendorCategoryID] [int] IDENTITY(1,1) NOT NULL,

[VendorID] [int] NOT NULL,

[VendorCategoryName] [nvarchar](50) NOT NULL,

[VendorCategoryDescription] [nvarchar](max) NULL,

[VendorParentCategoryID] [int] NULL,

[DateCreated] [datetime] NULL





Now I'm trying to create a Parent / Child relationship on this entity object to itself. Problem I'm having is that when I go to the mapping details for this association I select my table VendorCategory then I am presented with two rows for mapping navigation.

The first one I can map to the VendorCategoryID field to VendorParentCategoryID field. But on the second row I cannot map from VendorParentCategory to VendorCAtegoryID. WHen I try to build the library I get the following:

Error 1 Error 2027: If some of the EntitySet or the AssociationSet mapped to the same store EntitySet, and one of the sets includes a function mapping, all related entity and AssociationSets in the EntityContainer must also define function mappings. The following sets require function mappings: VendorCategoryVendorCategory.
C:\Projects\micsan\MicsanWebSite\SpikeTek\SpikeTek.NOP.Data\Model\NOPModel.edmx
510 11 SpikeTek.NOP.Data

Thanks,
Santiago



Nice idea, though I do not see a real advantage for the user - I try to keep the format compact.
Can you motivate me some for on this feature?
No Child Left Behind
0

#3 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 301
  • Joined: 17-September 08

Posted 12 February 2012 - 05:10 PM

Hi,

Can you ask general EF questions that are unrelated to the book on a public forum such as

http://social.msdn.m...amework/threads

or

www.stackoverflow.com.

I have a hard time keeping up with the book related questions as it is.

Thanks so much.

Julie
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users