Subset of data appearing in Mongo but not Realm (despite being added in Realm)

Hi,

A little bit of background. I have created an application which has taken the data from a SQL database and has added it into Mongo. From here I created a Realm based app using dotnet MAUI which has all worked fine until I wanted to add an array of class I called PatternImage as part of primary object called Pattern.

I added this in as can be seen below:

public class Pattern : RealmObject
    {

        [PrimaryKey]
        [MapTo("_id")]
        public ObjectId Id { get; set; }

        public Guid UserId { get; set; }

        public DateTimeOffset DateCreated { get; set; }

        public DateTimeOffset DateUpdated { get; set; }

        public string? PatternNumber { get; set; } 

        public string? Description { get; set; }

        public int? BustInInches { get; set; }

        public int? WaistInInches { get; set; }

        public ObjectId? DecadeTypeId { get; set; }

        public ObjectId? GarmentTypeId { get; set; }

        public bool IsFavourite { get; set; }

        public IList<PatternImage> PatternImages { get; }

    }

This is how I see this needing to be configured according to the documentation.

I added a PatternImage and this adds fine and appears in the MongoDb without a problem but then disappears from the Realm and I’m getting the following error:

Failed to transform received changeset: Schema mismatch: Link property 'PatternImages' in class 'Pattern' points to class 'PatternImage' on one side and to 'Pattern_PatternImages' on the other. (ProtocolErrorCode=201)

Without ripping my code apart, I’m trying to understand what I need to do to fix this and am looking for suggestions.

public class PatternImage : EmbeddedObject
    {

        public string StoragePath { get; set; }

        public string ImageFilePath { get; set; }

        public bool IsMainImage { get; set; }

    }

Hi, this is happening because of a divergence in the schemas between the backend (App Services UI) and the Realm Data Model. You have an “embedded object” that has a title of “PatternImage” in Realm but in AppServices the name is “Pattern_PatternImage”. This naming tells me that you defined the embedded object in the JSON Schema section for the App Services UI but did not give that object a “title” so we infer it to be the {parent_table_name}_{field_name}.

Your best move forward is likely to add a “title” field of “PatternImage” to the embedded object’s schema in the JSON Schema. Note that this will be a “breaking” change and we will prompt you to terminate and re-enable sync.

Let me know if this works!
Tyler

Excellent. Thank you so much, this is something I had on a previous project and effectively worked around it but nice to know how to address properly going forward!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.