A value converter maps one property to one column. Money has two parts, amount and currency, so a converter can only store it in one column: either a string like "12.50 AUD" or by dropping the currency. Either way SQL cannot filter, sort or SUM on the amount, cannot enforce the currency with a column constraint, and the LINQ query has to compare the whole converted value. A complex type (ComplexProperty(o => o.Total), EF Core 8+) maps Money to two typed columns in the owner's table (Total_Amount decimal(18,2), Total_Currency char(3)), so Where(o => o.Total.Amount > 100) and Sum translate to SQL. It has value semantics (no key, no identity, compared by value), works with immutable records, and lets Money keep its own behaviour, such as refusing to add AUD to NZD. Use a converter for single-value objects like OrderId or Email.
"The deciding fact is how many columns the value needs. A value converter turns one CLR property into one column value. That's perfect for
OrderIdwrapping aGuidorMoneyis two facts, an amount and a currency. With a converter I'd have to squash them into one column, a string or a JSON blob, and then the database can't do arithmetic on the amount: noWHERE Amount > 100, noSUM, no index on it, and no check constraint on the currency code.A complex type is made for this.
ComplexProperty(o => o.Total)mapsMoneytoTotal_AmountandTotal_Currencyin theOrderstable, each properly typed. LINQ likeorders.Where(o => o.Total.Amount > 100).Sum(o => o.Total.Amount)becomes plain SQL. And because a complex type has no key, EF Core treats it as a value: two orders can hold equalMoneyvalues, and replacingTotalwith a new record is the normal way to change it.That also keeps the domain clean.
Moneyis an immutable record with methods likeAddthat throw on mismatched currencies, and persistence doesn't leak into it."
public sealed record Money(decimal Amount, string Currency)
{
public Money Add(Money other) => other.Currency == Currency
? this with { Amount = Amount + other.Amount }
: throw new InvalidOperationException("Currency mismatch.");
}
modelBuilder.Entity<Order>().ComplexProperty(o => o.Total, m =>
{
m.Property(x => x.Amount).HasPrecision(18, 2);
m.Property(x => x.Currency).HasMaxLength(3).IsFixedLength().IsUnicode(false);
});
SELECT SUM([o].[Total_Amount]) FROM [Orders] AS [o] WHERE [o].[Total_Amount] > 100.0;
| Value converter | Complex type | |
|---|---|---|
| Columns | One | One per member |
| Query on parts | No | Yes |
| Best for | OrderId, Email, enums as strings |
Money, Address, DateRange |
An invoicing model stored totals as "123.45 AUD" strings; monthly revenue reports loaded [~400k] rows to sum in memory. Moving to a complex type let SQL do the SUM and cut the report from [40 s] to [under 1 s].
Checks the boundary between converters and complex types.
Last updated 23 Nov 2026.