Skip to content

CreatedAt metadata property mapping issue #4575

Description

@sbalocky

Hi team,

After upgrading from Marten v8.* to v9.2, the CreatedAt metadata property is no longer mapping correctly to my entity model. Other metadata properties (LastModified and Revision) are still mapping without any issues.

Steps to Reproduce / Configuration:

options.Schema.For<WebToSmsProgress>()
       .DatabaseSchemaName(schema)
       .Metadata(m =>
        {
            m.LastModified.MapTo(f => f.LastModifiedOn);
            m.CreatedAt.MapTo(f => f.CreatedOn); // <--- Failing to map in v9
            m.Revision.MapTo(f => f.Version);
        });

The entity gets created via a projection:

    public static async Task<WebToSmsProgress> Create(IQuerySession session, RequestedEvent @event)
    {
        SendSmsInboundData? data = await session.Query<SendSmsInboundData>().SingleOrDefaultAsync(f => f.Id == @event.SmsDataReferenceId);

        if (data is null)
        {
            return null!;
        }

        WebToSmsProgress progress = WebToSmsProgress.CreateInstance(
            @event.TransactionId,
            @event.ConfigurationId,
            @event.SmsDataReferenceId,
            @event.StreamId,
            MessageValidity.CreateInstance(@event.ValidUntil),
            requestReceivedOn: @event.RequestReceivedOn,
            progressData: new(Configuration: data.CurrentConfig, RecipientPhoneNumbers: data.RecipientPhoneNumbers));

        return progress;
    }

Actual Behavior:
When loading the data from the database, the createdOn property remains at its default DateTime value (0001-01-01), while lastModifiedOn and version populate correctly:

{
   "id": "f7492149-22f9-4ff3-9909-7cc6d206abf7",
   "version": 3,
   "streamId": "f7492149-22f9-4ff3-9909-7cc6d206abf7",
   "createdOn": "0001-01-01T00:00:00+00:00",
   "isArchived": false,
   "validUntil": "2026-05-29T00:53:55.1291389+02:00",
   "abortReason": "None",
   "lastModifiedOn": "2026-05-28T10:53:55.966507+00:00"
}

Expected Behavior:
The CreatedAt metadata should populate the CreatedOn property on the model just as it did in Marten v8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions