Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: Designer: DDL Generation Template for SQL CE should seperate each statemenet with GO [824]

$
0
0
Currently this is not the case for all statements, and it would be consistent and convenient if this was the case.
Comments: The benefit would be that the script is consistent and reliable. It is only foreign key constraints that lack the GO, all other statements have it. I will blog about the required change. ``` <# foreach (AssociationSet associationSet in Store.GetAllAssociationSets()) { ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single(); AssociationSetEnd dependentSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.ToRole).Single(); AssociationSetEnd principalSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.FromRole).Single(); string schemaName = Id(dependentSetEnd.EntitySet.GetSchemaName()); string dependentTableName = Id(dependentSetEnd.EntitySet.GetTableName()); string principalTableName = Id(principalSetEnd.EntitySet.GetTableName()); #> -- Creating foreign key on <#=WriteColumns(constraint.ToProperties, ',')#> in table '<#=dependentTableName#>' ALTER TABLE <#if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=dependentTableName#>] ADD CONSTRAINT [<#=WriteFKConstraintName(constraint)#>] FOREIGN KEY (<#=WriteColumns(constraint.ToProperties, ',')#>) REFERENCES <# if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=principalTableName#>] (<#=WriteColumns(constraint.FromProperties, ',')#>) ON DELETE <#=GetDeleteAction(constraint)#> ON UPDATE NO ACTION; GO <# // if the foreign keys are part of the primary key on the dependent end, then we should not add a constraint. if (!dependentSetEnd.EntitySet.ElementType.GetKeyProperties().Take(constraint.ToProperties.Count()).OrderBy(r => r.Name).SequenceEqual(constraint.ToProperties.OrderBy(r => r.Name))) { #> -- Creating non-clustered index for FOREIGN KEY '<#=WriteFKConstraintName(constraint)#>' CREATE INDEX [IX_<#=WriteFKConstraintName(constraint)#>] ON <#if (!IsSQLCE) {#>[<#=schemaName#>].<#}#>[<#=dependentTableName#>] (<#=WriteColumns(constraint.ToProperties, ',')#>); GO <# } #> <# } #> -- -------------------------------------------------- -- Script has ended -- -------------------------------------------------- ```

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>