This question is locked. New answers and comments are not allowed.
I am getting following error while setting up 1:1 relation
"Only bi-directional associations are allowed in a 1:1 autoinc setup. 'Models.Class1' is set to be autoinc."
Here are the tables
TBLClass1:
Class1Id - Identity
Property1
TBLClass2:
Class2Id - Identity
Class1Id - Foreign key to class1
Property2
Here are the classes
BaseClass:
Id
Class1: BaseClass
String Property1
Class2 objectA
Class2: BaseClass
string Property2
int class1id
Class1 objectB
Here is the mapping
Base:
MappingConfiguration<BaseClass> baseConfiguration = new MappingConfiguration<BaseClass>();
baseConfiguration.MapType().Inheritance(Telerik.OpenAccess.InheritanceStrategy.Horizontal);
Class1
MappingConfiguration<Class1> configuration = new MappingConfiguration<Class1>();
configuration.MapType(x => new { Property1 = x.Property1 }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("TBLClass1");
configuration.HasProperty(x => x.Id).ToColumn("Class1Id").IsIdentity(KeyGenerator.Autoinc);
configuration.HasAssociation(x => x.objectA).WithOpposite(x => x.objectB).ToColumn("Class1Id");
Class2
MappingConfiguration<Class2> configuration = new MappingConfiguration<Class2>();
configuration.MapType(x => new { Property2 = x.Property2 }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("TBLClass2");
configuration.HasProperty(x => x.Id).ToColumn("Class2Id").IsIdentity(KeyGenerator.Autoinc);
configuration.HasProperty(x => x.class1id).ToColumn("class1id");
configuration.HasAssociation(x => x.AssemblyHeader).WithOpposite(x => x.AssemblyOptions).ToColumn("AssemblyHeaderId").HasConstraint((x, y) => x.class1id == y.Id).IsRequired();
Let me know if I am missing anything here.
Thanks,
Paresh
"Only bi-directional associations are allowed in a 1:1 autoinc setup. 'Models.Class1' is set to be autoinc."
Here are the tables
TBLClass1:
Class1Id - Identity
Property1
TBLClass2:
Class2Id - Identity
Class1Id - Foreign key to class1
Property2
Here are the classes
BaseClass:
Id
Class1: BaseClass
String Property1
Class2 objectA
Class2: BaseClass
string Property2
int class1id
Class1 objectB
Here is the mapping
Base:
MappingConfiguration<BaseClass> baseConfiguration = new MappingConfiguration<BaseClass>();
baseConfiguration.MapType().Inheritance(Telerik.OpenAccess.InheritanceStrategy.Horizontal);
Class1
MappingConfiguration<Class1> configuration = new MappingConfiguration<Class1>();
configuration.MapType(x => new { Property1 = x.Property1 }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("TBLClass1");
configuration.HasProperty(x => x.Id).ToColumn("Class1Id").IsIdentity(KeyGenerator.Autoinc);
configuration.HasAssociation(x => x.objectA).WithOpposite(x => x.objectB).ToColumn("Class1Id");
Class2
MappingConfiguration<Class2> configuration = new MappingConfiguration<Class2>();
configuration.MapType(x => new { Property2 = x.Property2 }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable("TBLClass2");
configuration.HasProperty(x => x.Id).ToColumn("Class2Id").IsIdentity(KeyGenerator.Autoinc);
configuration.HasProperty(x => x.class1id).ToColumn("class1id");
configuration.HasAssociation(x => x.AssemblyHeader).WithOpposite(x => x.AssemblyOptions).ToColumn("AssemblyHeaderId").HasConstraint((x, y) => x.class1id == y.Id).IsRequired();
Let me know if I am missing anything here.
Thanks,
Paresh