From f07e5df865eea9b5940aecb938cf46742e16eeb7 Mon Sep 17 00:00:00 2001 From: David Vreony Date: Fri, 20 Dec 2024 14:22:03 +0000 Subject: [PATCH] efcore: generate noaction for ondelete (#527) --- ...ameworkEntityTypeConfigurationGeneratorProcessor.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Dhgms.Nucleotide.Generators/Features/EntityFramework/EntityFrameworkEntityTypeConfigurationGeneratorProcessor.cs b/src/Dhgms.Nucleotide.Generators/Features/EntityFramework/EntityFrameworkEntityTypeConfigurationGeneratorProcessor.cs index 297e622b..555573d4 100644 --- a/src/Dhgms.Nucleotide.Generators/Features/EntityFramework/EntityFrameworkEntityTypeConfigurationGeneratorProcessor.cs +++ b/src/Dhgms.Nucleotide.Generators/Features/EntityFramework/EntityFrameworkEntityTypeConfigurationGeneratorProcessor.cs @@ -387,6 +387,11 @@ private StatementSyntax GetEfChildRelationshipInvocation( "HasPrincipalKey", new[] { $"principal => principal.Id" }); + fluentApiInvocation = RoslynGenerationHelpers.GetFluentApiChainedInvocationExpression( + fluentApiInvocation, + "OnDelete", + new[] { $"global::Microsoft.EntityFrameworkCore.DeleteBehavior.NoAction" }); + return SyntaxFactory.ExpressionStatement(fluentApiInvocation); } @@ -415,6 +420,11 @@ private StatementSyntax GetEfParentRelationshipInvocation( "HasPrincipalKey", new[] { $"principal => principal.Id" }); + fluentApiInvocation = RoslynGenerationHelpers.GetFluentApiChainedInvocationExpression( + fluentApiInvocation, + "OnDelete", + new[] { $"global::Microsoft.EntityFrameworkCore.DeleteBehavior.NoAction" }); + return SyntaxFactory.ExpressionStatement(fluentApiInvocation); }