@@ -197,8 +197,7 @@ Namespace Scaffolding.Internal
197197 Dim firstProperty = True
198198 For Each prop in entityType.GetProperties()
199199 Dim propertyFluentApiCalls = prop.GetFluentApiCalls(annotationCodeGenerator)?.
200- FilterChain( Function (c) Not (Options.UseDataAnnotations AndAlso c.IsHandledByDataAnnotations) AndAlso
201- Not (c.Method = "IsRequired" AndAlso Options.UseNullableReferenceTypes AndAlso Not prop.ClrType.IsValueType))
200+ FilterChain( Function (c) Not (Options.UseDataAnnotations AndAlso c.IsHandledByDataAnnotations))
202201
203202 If propertyFluentApiCalls Is Nothing Then
204203 Continue For
@@ -238,8 +237,8 @@ Namespace Scaffolding.Internal
238237 Me .Write( Me .ToStringHelper.ToStringWithCulture(foreignKey.DependentToPrincipal.Name))
239238 Me .Write( ")." )
240239 Me .Write( Me .ToStringHelper.ToStringWithCulture( If (foreignKey.IsUnique, "WithOne" , "WithMany" )))
241- Me .Write( "(Function(p) p. " )
242- Me .Write( Me .ToStringHelper.ToStringWithCulture(foreignKey.PrincipalToDependent. Name))
240+ Me .Write( "(" )
241+ Me .Write( Me .ToStringHelper.ToStringWithCulture( If ( foreignKey.PrincipalToDependent IsNot Nothing , $ "Function(p) p.{foreignKey.PrincipalToDependent. Name}" , "" ) ))
243242 Me .Write( ")" )
244243 Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(foreignKeyFluentApiCalls, indent:= 6 )))
245244 Me .Write( "" & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 ))
@@ -276,11 +275,11 @@ Namespace Scaffolding.Internal
276275 Me .Write( "," & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 )& " Function(r) r.HasOne(Of " )
277276 Me .Write( Me .ToStringHelper.ToStringWithCulture(right.PrincipalEntityType.Name))
278277 Me .Write( ")().WithMany()" )
279- Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(rightFluentApiCalls, indent:= 7 )))
278+ Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(rightFluentApiCalls, indent:= 8 )))
280279 Me .Write( "," & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 )& " Function(l) l.HasOne(Of " )
281280 Me .Write( Me .ToStringHelper.ToStringWithCulture(left.PrincipalEntityType.Name))
282281 Me .Write( ")().WithMany()" )
283- Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(leftFluentApiCalls, indent:= 7 )))
282+ Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(leftFluentApiCalls, indent:= 8 )))
284283 Me .Write( "," & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 )& " Sub(j)" & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 ))
285284
286285 Dim joinKey = joinEntityType.FindPrimaryKey()
@@ -323,6 +322,24 @@ Namespace Scaffolding.Internal
323322
324323 Next
325324
325+ For Each prop in joinEntityType.GetProperties()
326+ Dim propertyFluentApiCalls = prop.GetFluentApiCalls(annotationCodeGenerator)
327+ If propertyFluentApiCalls Is Nothing Then
328+ Continue For
329+ End If
330+
331+ importsList.AddRange(propertyFluentApiCalls.GetRequiredUsings())
332+
333+ Me .Write( " j.IndexerProperty(Of " )
334+ Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Reference(prop.ClrType)))
335+ Me .Write( ")(" )
336+ Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Literal(prop.Name)))
337+ Me .Write( ")" )
338+ Me .Write( Me .ToStringHelper.ToStringWithCulture(code.Fragment(propertyFluentApiCalls, indent:= 8 )))
339+ Me .Write( "" & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 ))
340+
341+ Next
342+
326343 Me .Write( " End Sub)" & Global .Microsoft.VisualBasic.ChrW( 13 )& Global .Microsoft.VisualBasic.ChrW( 10 ))
327344
328345 anyEntityTypeConfiguration = True
0 commit comments