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));

            MyConsumerProfileFacet facet = new MyConsumerProfileFacet ();
            facet.Email = "myemail@gmail.com";
            facet.LastName = "aaaaaaaa";
            facet.FirstName = "bbbbbbb";

             client.SetFacet(contact, MyConsumerProfileFacet .DefaultFacetKey, facet);



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=, 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 ?

  • Can you also post custom facet c# class? Have you patched also XConnect.Client with your custom facet? See last chapter of this article doc.sitecore.net/developers/xp/xconnect/xconnect-model/… . We had similar issue and this solved it – Peter Procházka Jun 5 '18 at 8:07
  • @PeterProchazka please add your answer, I just added my model into a config file and it works. I had before this issue but I forgot about it.. . – Vlad Iobagiu Jun 5 '18 at 8:22
  • Glad I could help you Vlad. It was lucky shot or good gut feeling... ;) – Peter Procházka Jun 5 '18 at 9:12

You need to add your custom model into config file which will patch \App_Config\Sitecore\XConnect.Client.Configuration\Sitecore.XConnect.Client.config at the end.

Something similar to this code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <runtime type="Sitecore.XConnect.Client.Configuration.RuntimeModelConfiguration,Sitecore.XConnect.Client.Configuration">
        <schemas hint="list:AddModelConfiguration">
            <!-- value of 'name' property must be unique -->
            <schema name="documentationmodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration" patch:after="schema[@name='collectionmodel']">
                <param desc="modeltype">Documentation.Model.CollectionModel, Documentation.Model</param>

More information can be found here: https://doc.sitecore.net/developers/xp/xconnect/xconnect-model/managing-model/deployment.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.