How are you guys handling multiple version of a marketingautomationengine
model in your current solution.
Let's assume I have mymodel,1.0.json
which looks like below
{
"Name": "mymodel",
"Version": "1.0",
"References": [
{
"Name": "XConnect",
"Version": "1.0"
},
{
"Name": "Sitecore.XConnect.Collection.Model",
"Version": "9.0"
}
],
"Types": {
"My.Project.Namespace.Facets.Model1": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "My.Project.Namespace.Facets.Model1, My.Project.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"Id": {
"Type": "String"
},
"Name": {
"Type": "String"
},
"SomeProp": {
"Type": "String"
}
}
},
"My.Project.Namespace.Facets.Model2": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "My.Project.Namespace.Facets.Model2, My.Project.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"SomeOtherId": {
"Type": "String"
},
"CustomerName": {
"Type": "String"
},
"PostalCode": {
"Type": "String"
}
}
},
"My.Project.Namespace.Facets.Model3": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "My.Project.Namespace.Facets.Model3, My.Project.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"Lorem": {
"Type": "String"
}
}
}
},
"Facets": [
{
"Target": "Contact",
"Name": "FacetName1",
"Type": "My.Project.Namespace.Facets.Model1"
},
{
"Target": "Contact",
"Name": "FacetName2",
"Type": "My.Project.Namespace.Facets.Model2"
},
{
"Target": "Contact",
"Name": "FacetName3",
"Type": "My.Project.Namespace.Facets.Model3"
}
]
}
And I want to modify this model definition by removing the FacetName2
definition, but instead of generating a MarketingAutomation
model with the same version number, I would increase its version to 2.0 so it would look like this.
Model name would be mymodel,2.0.json
{
"Name": "mymodel",
"Version": "2.0",
"References": [
{
"Name": "XConnect",
"Version": "1.0"
},
{
"Name": "Sitecore.XConnect.Collection.Model",
"Version": "9.0"
}
],
"Types": {
"My.Project.Namespace.Facets.Model1": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "My.Project.Namespace.Facets.Model1, My.Project.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"Id": {
"Type": "String"
},
"Name": {
"Type": "String"
},
"SomeProp": {
"Type": "String"
}
}
},
"My.Project.Namespace.Facets.Model3": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "My.Project.Namespace.Facets.Model3, My.Project.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"Lorem": {
"Type": "String"
}
}
}
},
"Facets": [
{
"Target": "Contact",
"Name": "FacetName1",
"Type": "My.Project.Namespace.Facets.Model1"
},
{
"Target": "Contact",
"Name": "FacetName3",
"Type": "My.Project.Namespace.Facets.Model3"
}
]
}
At this point, mymodel,1.0.json
and mymodel,2.0.json
are both present in the folder \App_data\jobs\continuous\IndexWorker\App_data\Models
and Xconnect\App_Data\Models
And I get
2020-04-22 12:15:20.712 +02:00 [Error] XConnect Web Application Error: "System.ApplicationException: Exception trying to initialize Service Collection and Provider for WebAPI Dependency Resolver, Inner Exception: Different models with the same names are referenced ('mymodel') ---> Sitecore.XConnect.Schema.DuplicateXdbModelNameException: Different models with the same names are referenced ('mymodel')
at Sitecore.XConnect.Schema.XdbModel.AddAndValidateModelAndTypes(XdbModel model, HashSet`1 visited)
at Sitecore.XConnect.Schema.XdbModel.AddAndValidateModelAndTypes(XdbModel model, HashSet`1 visited)
at Sitecore.XConnect.Schema.XdbModel..ctor(String name, XdbModelVersion version, XdbNamedType[] types, XdbFacetDefinition[] facets, XdbModel[] referencedModels)
at Sitecore.XConnect.Schema.XdbRuntimeModel..ctor(XdbModel[] models)
at Sitecore.XConnect.Web.Extensions.UseXConnectModel(IServiceCollection services)
at Sitecore.XConnect.DependencyInjection.ServiceCollectionExtensions.GetXConnectServiceConfiguration(IServiceCollection services)
at Sitecore.XConnect.Web.WebApiConfig.ConfigureServices(HttpConfiguration config)
--- End of inner exception stack trace ---
at Sitecore.XConnect.Web.WebApiConfig.ConfigureServices(HttpConfiguration config)
at System.Web.Http.GlobalConfiguration.Configure(Action`1 configurationCallback)
at Sitecore.XConnect.Web.Global.Application_Start(Object sender, EventArgs e)"
How would you guys handle this kind of situation?