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)
.HasColumnType("Money");Written by Blaise Liu
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Entity framework
Authors
blaiseliu
10.36K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#