I am trying to create custom facets on new contacts.
I am using this code :
using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
{
var model = client.Model;
Contact contact = new Contact(new ContactIdentifier("external", Guid.NewGuid().ToString(), ContactIdentifierType.Known));
client.AddContact(contact);
MyConsumerProfileFacet facet = new MyConsumerProfileFacet ();
facet.Email = "[email protected]";
facet.LastName = "aaaaaaaa";
facet.FirstName = "bbbbbbb";
client.SetFacet(contact, MyConsumerProfileFacet .DefaultFacetKey, facet);
client.Submit();
}
On submit I have next exception : The type of this instance does not correspond to any type in the model
On xConnect I deployed my json model and it looks like :
"Types": {
"X.Feature.DynamicsCrm.Facets.ConsumerProfileFacet": {
"Type": "Facet",
"BaseType": "Sitecore.XConnect.Facet",
"ClrType": "X.Feature.DynamicsCrm.Facets.ConsumerProfileFacet, X.Feature.DynamicsCrm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"Properties": {
"Websitegroup": {
"Type": "String"
},
"Subscribetoportalnews": {
"Type": "String"
},
"Subscribetoportalemail": {
"Type": "String"
},
"Subscribetoportalblog": {
"Type": "String"
},
"Email": {
"Type": "String"
},
// other properties
}
}
If I used default Facets it works perfectly.
What I am doing wrong ?