have a quite old Database, one details have 0 or 1 trainer.
TABLE [dbo].[DETAILS] (
[SEDETID] INT IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
TABLE [dbo].[TRAINER] (
[SemTrainID] INT IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
[SEDETID] INT DEFAULT ((0)) NOT NULL,
should map with SEDETID, maps with semtrainid->sedetid
Have in both classes virtual (overrideable) propertys
and in Dbcontext class a more conceptual code, how to map the correct columns=
modelBuilder.Entity(Of DETAILS)() _
.HasOptional(Function(e) e.Trainer) _
.WithOptionalDependent(Function(f) f.details) _
.Map(Function(g) g.MapKey("SEDETID"))
modelBuilder.Entity(Of TRAINER)() _
.HasOptional(Function(e) e.details) _
.WithRequired(Function(f) f.Trainer) _
.Map(Function(g) g.MapKey("SEDETID"))
Thanks Hannes