In this blog post: EF4 Code First Control Unicode and Decimal Precision, Scale with Attributes, Dane Morgridge used attributes to control the creation of di
For example, consider this Invoice class:
public class Invoice
{
public int InvoiceId { get; set; }
public decimal Amount { get; set; }
}
You can do it with fluent API:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
.Property(i => i.Amount)
.HasColumnType("Money");
}
Or you can do it with Data Annotations:
public class Invoice
{
public int InvoiceId { get; set; }
[Column(TypeName="Money")]
public decimal Amount { get; set; }
}