@@ -708,28 +708,25 @@ private void GenerateNavigationDataAnnotations(IEntityType entityType, ISkipNavi
708708
709709 private void GenerateForeignKeyAttribute ( IEntityType entityType , ISkipNavigation navigation )
710710 {
711- if ( navigation . IsOnDependent )
711+ if ( navigation . ForeignKey . PrincipalKey . IsPrimaryKey ( ) )
712712 {
713- if ( navigation . ForeignKey . PrincipalKey . IsPrimaryKey ( ) )
714- {
715- var foreignKeyAttribute = new AttributeWriter ( nameof ( ForeignKeyAttribute ) ) ;
713+ var foreignKeyAttribute = new AttributeWriter ( nameof ( ForeignKeyAttribute ) ) ;
716714
717- if ( navigation . ForeignKey . Properties . Count > 1 )
718- {
719- foreignKeyAttribute . AddParameter (
720- CSharpHelper . Literal (
721- string . Join ( "," , navigation . ForeignKey . Properties . Select ( p => EntityTypeTransformationService . TransformNavPropertyName ( entityType , p . Name , p . ClrType . Name ) ) ) ) ) ;
722- }
723- else
724- {
725- foreignKeyAttribute . AddParameter ( $ "nameof({ EntityTypeTransformationService . TransformNavPropertyName ( entityType , navigation . ForeignKey . Properties . First ( ) . Name , navigation . ForeignKey . Properties . First ( ) . ClrType . Name ) } )") ;
726- }
727-
728- NavPropertyAnnotations . Add ( new Dictionary < string , object >
729- {
730- { "nav-property-annotation" , foreignKeyAttribute }
731- } ) ;
715+ if ( navigation . ForeignKey . Properties . Count > 1 )
716+ {
717+ foreignKeyAttribute . AddParameter (
718+ CSharpHelper . Literal (
719+ string . Join ( "," , navigation . ForeignKey . Properties . Select ( p => EntityTypeTransformationService . TransformNavPropertyName ( entityType , p . Name , p . ClrType . Name ) ) ) ) ) ;
732720 }
721+ else
722+ {
723+ foreignKeyAttribute . AddParameter ( $ "nameof({ EntityTypeTransformationService . TransformNavPropertyName ( entityType , navigation . ForeignKey . Properties . First ( ) . Name , navigation . ForeignKey . Properties . First ( ) . ClrType . Name ) } )") ;
724+ }
725+
726+ NavPropertyAnnotations . Add ( new Dictionary < string , object >
727+ {
728+ { "nav-property-annotation" , foreignKeyAttribute }
729+ } ) ;
733730 }
734731 }
735732
0 commit comments