Last Updated: February 25, 2016
· blaiseliu

How to use Entity Framework Code First to create SQL Server money type?

There are a few data types in SQL server that have no corresponding type in C#, like money.

Here is what we are going to do.

In the domain models:

public decimal Price { get; set; }

Please note it has to be decimal. A double will not work.

And in the OnModelCreating method of the fluent api:

Property(i => i.Amount)

Have a fresh tip? Share with Coderwall community!

Post a tip