EF Core for MongoDB: Decimal Data Tye

Does EF for MongoDB support the decimal data type from .NET out of the box? Or does a serializer still need to be registered?

Hi @Nicholas_Vella,

You can use the .NET Decimal data type or Decimal 128 but by default but it maps to a string in MongoDB. However, you can use the BsonRepresentation attribute ([BsonRepresentation(BsonType.Decimal128)]) or the Fluent API with the EF Core provider to specify decimal 128 storage. Separately, we are planning to change the default in the next major version of the .NET/C# driver, you can track the progress of that in this ticket. Hope that helps.

Thanks,

Rishit.

Thank you for the clarification @Rishit_Bhatia

1 Like