ForeignKey added via code does not work
I add a foreignkey via code in Metatadacontainer, but once I add TableA and TableB the link is not created.
If I see the metadata via EditMetadataContainer I can see on TableA the MyforeignkytoB, but seems that the two fields are not linked.
What's wrong ?
thanks
If I see the metadata via EditMetadataContainer I can see on TableA the MyforeignkytoB, but seems that the two fields are not linked.
What's wrong ?
thanks
Dim md As MetadataContainer
Dim mov As MetadataObject
Dim r As MetadataForeignKey
Dim f As MetadataField
md.BeginUpdate()
'TABELLA: Movimenti
mov = md.AddTable( "Movimenti" )
mov.AltName = "Movimenti"
f = mov.AddField("Data1") : f.FieldType = DbType.Date : f.AltName = "DataCompetenza"
t = md.AddTable("Tempo") : t.AltName = "Tempo"
f = t.AddField("Giorno") : f.FieldType = DbType.Date : f.AltName = "Giorno"
r = mov.AddForeignKey( "MovimentiToTempo" )
Using name As New MetadataQualifiedName()
name.Add("Tempo")
r.ReferencedObjectName = name
End Using
r.AddField( "Data1" ) : r.ReferencedFields.Add( "Giorno" )
--------------------------------------
at the end, I can see the ForeignKey MovimentiToTempo but there isn't any link between the field Data1 and the field Giorno
thank you
qb.OfflineMode = True
qb.MetadataProvider = Nothing
md = qb.MetadataContainer
I create the metadatacontainer all by code.