Hello,
This is the code we are using, I left out some properties to make it more readable.
This is our entity:
namespace Domain.EntityClasses
{
public partial class PrePaidTransaction : CommonEntityBase
{
partial void OnCreated();
public PrePaidTransaction() : base()
{
OnCreated();
}
public System.Decimal BalanceNew { get; set; }
public System.Decimal BalanceOld { get; set; }
public System.Decimal Credits { get; set; }
}
}
Mapping:
protected virtual void MapPrePaidTransaction(EntityTypeBuilder<PrePaidTransaction> config)
{
config.ToTable("PrePaidTransaction");
config.Property(t => t.Credits);
config.Property(t => t.BalanceOld);
config.Property(t => t.BalanceNew);
}
Table:
CREATE TABLE [dbo].[PrePaidTransaction](
[Credits] [decimal](18, 3) NOT NULL,
[BalanceOld] [decimal](18, 3) NOT NULL,
[BalanceNew] [decimal](18, 3) NOT NULL
)
Also, the context itself was not changed, just the auto-generated code.
Our injection (ConfigureServices in Startup.cs)
services.AddDbContext<OurContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("ConnectionString")));
services.AddScoped<DbContext, OurContext>();
In a unit test environment, I am also not really able to reproduce this, but when we deploy to Azure, we see these exceptions popping up in Sentry (warnings). Also when running the API locally, we can see these warnings in the DEBUG console.
More details:
- Web API project using .NET Core 3.1
- Persistence and Model projects using .NET Standard 2.1
Frank