This question is locked. New answers and comments are not allowed.
I have a table with self foreign key.
For mapping I'm using Artificial:
But
How map self foreign key right using artificial mapping?
Thanks.
CREATE TABLE [dbo].[Test]( [Id] [int] IDENTITY(1,1) NOT NULL, [ID_Parent] [int] NULL, [Code] [varchar](100) NULL, CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED ( [Id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]ALTER TABLE [dbo].[Test] WITH CHECK ADD CONSTRAINT [FK_Test_Test] FOREIGN KEY([ID_Parent])REFERENCES [dbo].[Test] ([Id])ALTER TABLE [dbo].[Test] CHECK CONSTRAINT [FK_Test_Test]MappingConfiguration configuration = new MappingConfiguration("Test", "ConsoleApp");
configuration.MapType().WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("Test");
var prop = configuration.HasArtificialAssociation("ID_Parent_fk", configuration.ConfiguredType);
prop.WithOppositeCollection("Tests");prop.ToColumn("ID_Parent");prop.HasConstraint();handler.CreateUpdateDDLScript generate script for deleting constraint.var handler = GetSchemaHandler();//script = 'ALTER TABLE [Test] DROP CONSTRAINT [FK_Test_Test]'
var script = handler.CreateUpdateDDLScript(new SchemaUpdateProperties());
if (!String.IsNullOrEmpty(script)) handler.ForceExecuteDDLScript(script);How map self foreign key right using artificial mapping?
Thanks.