简体   繁体   中英

Pomelo.EntityFrameworkCore.MySql Database first and Generated column

in my table I have a Generated column of Decimal type,

COLUMN `quantidadeTotal` DECIMAL(18,4) GENERATED ALWAYS AS (((`quantidade` + `quantidadeReservada`) + `quantidadeBloqueada`)) VIRTUAL;

which is the sum of 3 other columns also of Decimal type, the problem occurs when I execute "scaffold", the generated model comes with this column in this format

public decimal? QuantidadeTotal { get; set; }

and in generated context also has reference to the

entity.Property(e => e.QuantidadeTotal)
.HasColumnName("quantidadeTotal")
.HasColumnType("decimal(18,4)");

column if i try to insert some record in the table i get an error, even if not informing anything in the Generated column, i have to delete the reference of this column in the context and in the model to work. is there any configuration for scaffold to ignore this type of column or any special treatment?

if not, every time I make a scaffold I will have to adjust all fields manually, and it would be a lot of work.

Pomelo.EntityFrameworkCore.MySql v3.2.4

thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM