LLBLGen Pro version: 5.12 (5.12.1) RTM
.NET version: 8.0
Database: SQL Server 2017
Hi,
I'm currently customizing the ModelBuilder template to conditionally apply .UseSqlOutputClause(false) during inserts in EF Core, based on a custom property (UseSqlOutputClause) defined in OutputSettingValues.CustomProperties.
This helps us avoid issues with triggers and constraints in our database setup.
At the moment, I'm manually updating the generated ModelBuilder file in the LLBLGen application programs folder after each code generation run.
I'm not sure if LLBLGen already provides a built-in way to configure this behavior through the designer or metadata—if it does, I'd love to know how to use it.
If not, would it be possible to consider adding support for this in a future version, either as a per-entity setting or a global option?
Thanks in advance for your help!
Andreas
what i would like to achieve:
protected virtual void MapAddressEntity(EntityTypeBuilder<AddressEntity> config)
{
config.ToTable("Address", tb => tb.UseSqlOutputClause(false));
}
how i currently fixed it: (modelbuilder.lpt)
protected virtual void Map<%=entity.Name%>(EntityTypeBuilder<<%=entity.Name%>> config)
{
<% var useSqlOutput = false;
if(entity.OutputSettingValues.CustomProperties.ContainsKey("UseSqlOutputClause"))
{
useSqlOutput = entity.OutputSettingValues.CustomProperties["UseSqlOutputClause"].ToString().ToLower() == "true";
}
%>config.ToTable("<%=mapping.MappedTarget.Name%>"<%
if(mapping.MappedTarget.ContainingSchema.SchemaOwner!=defaultSchema) { %>, "<%=mapping.MappedTarget.ContainingSchema.SchemaOwner%>"<% }
if(supportsTemporalTables && targetIsTemporalTable) { %>, b=>b.IsTemporal(b=> { b.HasPeriodStart("<%=periodStartField.FieldName%>"); b.HasPeriodEnd("<%=periodEndField.FieldName%>");})<%}
if(!string.IsNullOrEmpty(tptDifferentPkTargetNames)) { %>, <%=tptDifferentPkTargetNames%><% }
if(useSqlOutput) { %>, tb => tb.UseSqlOutputClause(false)<% }
%>);
...