realm / realm-dotnet

Realm is a mobile database: a replacement for SQLite & ORMs
https://realm.io
Apache License 2.0
1.23k stars 159 forks source link

Getting exception The class TripModel is not in the limited set of classes for this realm #3638

Closed sledderGIT closed 3 weeks ago

sledderGIT commented 1 month ago

What happened?

Just started to get an exception System.ArgumentException: The class TripModel is not in the limited set of classes for this realm (Parameter 'T')

using Realms;

namespace CTeleport.Mobile.Core.RealmStore.Trips;

public class TripModel: RealmObject
{
    public TripModel()
    {
    }

    [Indexed]
    public DateTimeOffset EndingDate { get; set; }

    [Indexed]
    public DateTimeOffset CreatedAt { get; set; }

    [Indexed]
    public DateTimeOffset UpdatedAt { get; set; }

    [PrimaryKey]
    public string Id { get; set; }
    public string TravelerName { get; set; }
    public IList<BookingModel> Bookings { get; }
}

Repro steps

  1. RealmInstance.All<TripModel>().Count();
  2. System.ArgumentException: The class TripModel is not in the limited set of classes for this realm (Parameter 'T')

Version

.NET 8

What Atlas Services are you using?

Local Database only

What type of application is this?

Xamarin

Client OS and version

iOS simulator 17.2 Realm 12.2

Code snippets

No response

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

sync-by-unito[bot] commented 1 month ago

➤ PM Bot commented:

Jira ticket: RNET-1163

nirinchev commented 1 month ago

How do you open the Realm instance? Particularly, how does the config look like?

sledderGIT commented 1 month ago
    public async Task<Realm> GetRealmInstance(string id)
    {
        return await Realm.GetInstanceAsync(GetRealmConfig(id));
    }

    public RealmConfiguration GetRealmConfig(string id)
    {
        return new RealmConfiguration(id)
        {
            SchemaVersion = RealmVersion,
            ShouldDeleteIfMigrationNeeded = true
        };
    }

Nothing extrodinary I would say :)

nirinchev commented 1 month ago

Are the models that you use and the code that opens the Realm in the same assembly?

github-actions[bot] commented 3 weeks ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.