In SQL Server we can write data AS Numeric(15,10) .. what will the equivalent of this in C#?
I know that Numeric's equivalent is Decimal but how to represent Numeric(15,10)?
In SQL Server we can write data AS Numeric(15,10) .. what will the equivalent of this in C#?
I know that Numeric's equivalent is Decimal but how to represent Numeric(15,10)?
if you are using EntityFrameWorkCore there is a solution for this.
after defining DbContext in your project you can add configuration for the model as below:
public class ChequeEfConfiguration : IEntityTypeConfiguration<Cheque>
{
public void Configure(EntityTypeBuilder<Cheque> builder)
{
builder.Property(a => a.Amount).HasColumnType("decimal(18,2)");
}
}
or you can use OnModelCreating in your DbContext like this:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Cheque>().Property(x => x.Amount)
.IsRequired().HasColumnType("decimal(18,2)");
}
but I would recommend you to use the first one. for more information visit https://docs.microsoft.com/en-us/ef/core/modeling/