@@ -16,6 +16,7 @@ public class Migration_04_06_00_Pre_03 : IModuleMigration
1616 private const string HttpServiceSettingsStereotypeId = "c29224ec-d473-4b95-ad4a-ec55c676c4fd" ;
1717 private const string ServiceModelSpecializationTypeId = "b16578a5-27b1-4047-a8df-f0b783d706bd" ;
1818 private const string WebApiDefinitionPackageId = "0011387a-b122-45d7-9cdb-8e21b315ab9f" ;
19+ private const string RoutePropertyDefinitionId = "1e223bd0-7a72-435a-8741-a612d88e4a12" ;
1920
2021 public Migration_04_06_00_Pre_03 ( IApplicationConfigurationProvider configurationProvider )
2122 {
@@ -62,7 +63,7 @@ public void Up()
6263 [
6364 new StereotypePropertyPersistable
6465 {
65- DefinitionId = "1e223bd0-7a72-435a-8741-a612d88e4a12" ,
66+ DefinitionId = RoutePropertyDefinitionId ,
6667 Name = "Route" ,
6768 Value = "api/[controller]" ,
6869 IsActive = true
@@ -73,6 +74,28 @@ public void Up()
7374 element . Stereotypes . Add ( httpServiceSettings ) ;
7475 needsSave = true ;
7576 }
77+
78+ if ( httpServiceSettings is not null )
79+ {
80+ var routeProp = httpServiceSettings . Properties . FirstOrDefault ( p => p . DefinitionId == RoutePropertyDefinitionId ) ;
81+ if ( routeProp is null )
82+ {
83+ routeProp = new StereotypePropertyPersistable
84+ {
85+ DefinitionId = RoutePropertyDefinitionId ,
86+ Name = "Route" ,
87+ Value = "api/[controller]" ,
88+ IsActive = true
89+ } ;
90+ httpServiceSettings . Properties . Add ( routeProp ) ;
91+ needsSave = true ;
92+ }
93+ else if ( string . IsNullOrWhiteSpace ( routeProp . Value ) )
94+ {
95+ routeProp . Value = "api/[controller]" ;
96+ needsSave = true ;
97+ }
98+ }
7699 }
77100
78101 if ( needsSave )
@@ -103,7 +126,7 @@ public void Down()
103126 var httpServiceSettings = element . Stereotypes . FirstOrDefault ( p => p . DefinitionId == HttpServiceSettingsStereotypeId ) ;
104127 if ( httpServiceSettings != null )
105128 {
106- var routeProperty = httpServiceSettings . Properties . FirstOrDefault ( p => p . DefinitionId == "1e223bd0-7a72-435a-8741-a612d88e4a12" ) ;
129+ var routeProperty = httpServiceSettings . Properties . FirstOrDefault ( p => p . DefinitionId == RoutePropertyDefinitionId ) ;
107130 if ( routeProperty != null && routeProperty . Value == "api/[controller]" )
108131 {
109132 element . Stereotypes . Remove ( httpServiceSettings ) ;
0 commit comments