No persister for during save or update

9 views
Skip to first unread message

Michael W Powell

unread,
Jun 21, 2025, 4:09:28 PMJun 21
to Fluent NHibernate
Hello,

In my class map, I have the following.

public class DiscordGuidMap : DiscordModelBaseMap<DiscordGuild, SocketGuild>
{
    public DiscordGuidMap() : base()
    {
        Map(x => x.Name)
            .Length(DiscordModelBase.NameMaxLength)
            .Not.Nullable();

        Map(x => x.Description)
            .Length(DiscordGuild.DescriptionMaxLength)
            .Nullable();
 
        HasMany(x => x.TextChannels)
            .AsBag()
            .Cascade.AllDeleteOrphan().Inverse();
    }
}

There is an internal property Source which we pick up the SocketGuild in this case, and for DiscordTextChannel the SocketTextChannel as well.

These are properly unmapped, should not be mapped.

I got this to save or update "once" now does not seem to work again, getting the infamous "no persister for". Now with the exception messages:

- $exception {"An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.\r\n\r\n"} FluentNHibernate.Cfg.FluentConfigurationException
+ InnerException {"Could not determine type for: Discord.WebSocket.SocketGuild, Discord.Net.WebSocket, Version=3.15.3.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(Source)"} System.Exception {NHibernate.MappingException}

Note, there should NOT be a persister for Source, nor do we want to map that property, it is strictly for internal use only.

My mappings are properly configured including ClassMap<t> from the appropriate assemblies.

private static void OnMappingConfiguration<TMappingProvider, TConvention>(MappingConfiguration mappingConfiguration)
    where TMappingProvider : class, IMappingProvider
    where TConvention : class, IConvention
{
    mappingConfiguration.FluentMappings
        .Conventions.AddFromAssemblyOf<TConvention>()
        .AddFromAssemblyOf<TMappingProvider>();
}

private static (string appSettingsPath, Action<MappingConfiguration> onMapping, Action<Configuration> onExpose) _configurationHandlers = (
    "appsettings.json"
    , OnMappingConfiguration<CredentialMap, PrimaryKeyConvention>
    , delegate { }
);

And we deconstruct the tuple and use accordingly in the correct places. We're "this far" as evidence things are wired and plumbed correctly.

The only way we could be getting that exception is if somehow Source is somehow being seen and included in the map, which it should not be. And solutions I have seen in some forums to annotate with an [Ignore] or perhaps [NotMapped attribute, not a desirable approach, starts getting overtly invasive of the mapped models. Besides which, we are not auto mapping, but rather fluent ClassMap mapping.

Any thoughts how to contend with this?

Thank you!

Best,

Michael W. Powell

Michael W Powell

unread,
Jun 21, 2025, 5:04:49 PMJun 21
to Fluent NHibernate
Ah I see what I did. I was literally trying to save the unmapped SocketGuild, presented a different collection instance than the one I had intended. Oops!
Reply all
Reply to author
Forward
0 new messages