Closed DavidAllardyce closed 1 year ago
The lib registers temp tables for most primitive types. Temp table for decimal
is one of them.
You can provide a default value for precision and scale via ConfigureConventions
public class DemoDbContext : DbContext
{
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.Properties<decimal>(builder => builder
.HavePrecision(18, 5)
.HaveColumnType("decimal(18, 5)"));
}
Alternatively, you can configure the property in OnModelCreating
.
public class DemoDbContext : DbContext, IDbDefaultSchema
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
...
modelBuilder.ConfigureTempTable<decimal>(builder => builder.Property(t => t.Column1).HasPrecision(18, 5));
You can disable the registration of temp tables when calling AddBulkOperationSupport
.
new ServiceCollection()
.AddDbContext<SqlServerBenchmarkDbContext>(builder =>
builder.UseSqlServer(sqlServerConnString,
optionsBuilder => optionsBuilder.AddBulkOperationSupport(configureTempTablesForPrimitiveTypes: false)
Thanks for the detailed answer. Much appreciated!
I get the following warning on startup. I'm using EF Core 7 on .NET6 with MS SQL.
I checked all of my
Decimal
columns, but I can't seem to clear it.Has anyone seen this before?