I’m Currently trying to migrate my app from Partitionbased Sync to flexible Sync and ran into an Error without changing my Schema. ( I created a new App for this with flexible Sync in Atlas App Services and wanted to play around with it first). Tried to establish the Schema with Development Mode.
Currently, it says:
failed to update schema: error checking for queryable fields change: error fetching schema provider for schemas: at least two embedded schemas with different properties have the same title - “TrainingsSession” - property “exerciseForDay” has linking type “cross-collection link” in one schema and “none” in another: please terminate sync first if you wish to make changes to the embedded schemas that share a title (ProtocolErrorCode=225)
Trainingssession is an EmbeddObject that contains a list of RealmObjects (ExerciseForDay). Trainingssession itself is used in two different Places. A RealmObject (DiaryEntry ) and a EmbeddObject (TrainingsDay). Below are the relevant Classes (Only relevant Properties are displayed)
public partial class TrainingsSession : IEmbeddedObject
{
[MapTo("_id")] public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("exercisesForDay")] [BsonIgnore] public IList<ExerciseForDay> ExercisesForDay { get; }
}
public partial class ExerciseForDay : IRealmObject, ISortable, IEntity<ObjectId>
{
[PrimaryKey]
[MapTo("_id")]
[BsonElement("_id")]
[BsonId]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("partition")]
[BsonElement("partition")]
[BsonRequired]
public string Partition { get; set; } = string.Empty;
}
public partial class DiaryEntry : IRealmObject, IEntity<ObjectId>
{
[PrimaryKey]
[MapTo("_id")]
[BsonId]
[BsonElement("_id")]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("partition")]
[BsonElement("partition")]
[BsonRequired]
public string Partition { get; set; } = string.Empty;
[MapTo("sessions")]
[BsonElement("sessions")]
public IList<TrainingsSession> Sessions { get; }
}
public partial class TrainingsDay : IEmbeddedObject, IGroupable
{
[MapTo("_id")]
[BsonId]
[BsonElement("_id")]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("sessions")]
[BsonElement("sessions")]
public IList<TrainingsSession> Sessions { get; }
}
public partial class Week : IEmbeddedObject, IGroupable
{
[MapTo("_id")]
[BsonElement("_id")]
[BsonId]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("days")] [BsonElement("days")] public IList<TrainingsDay> Days { get; }
}
public partial class Trainingsplan : IRealmObject, IEntity<ObjectId>
{
[PrimaryKey]
[MapTo("_id")]
[BsonId]
[BsonElement("_id")]
public ObjectId Id { get; set; } = ObjectId.GenerateNewId();
[MapTo("partition")]
[BsonElement("partition")]
public string Partition { get; set; } = string.Empty;
[MapTo("weeks")]
[BsonElement("weeks")]
public IList<Week> Weeks { get; }
}
Do i miss something with the Relationships ? The given schema worked perfectly fine with the Partitionbased sync.