Hi,
I’m new to MongoDB.EntityFrameworkCore and I’m trying to use CamelCaseElementNameConvention in my solution. I’ve registered this convention before instantiating my DbContext. My entity class properties are named using PascalCase.
I was expecting that a class like the following:
public class User
{
public Guid UserId { get; private set; }
public string Username { get; private set; }
}
would be persisted as:
{
_id: UUID(‘5727f6b9-e4d1-458e-85f8-b761c32da765’),
username: “test”
}
However, the PascalCase notation is still being retained, and the document is stored as:
{
_id: UUID(‘5727f6b9-e4d1-458e-85f8-b761c32da765’),
Username: “test”
}
It seems that CamelCaseElementNameConvention is being ignored. Is this expected behavior? Does it only work with the native MongoDB driver’s serializer, or is it also supported by Entity Framework Core?
I’ve resorted to using the Fluent API method HasElementName, which works, but it would be great if this could be configured globally.
Also, I would prefer to avoid using attribute based decorators, as I’d like to keep my domain entities persistence agnostic.
Thanks in advance for your help.
Best regards,
David