how to prevent entity framework to change column names of just one of tables?

71 Views Asked by At

i have column names with "underline" in the names, when in update model from database entity frame work remove "underline" in the names, i use jsonPropertyName annotation for fix this issue , but when i update agin,json jsonPropertyNames remove.

            entity.Property(e => e.DesChkHecli)
                .HasMaxLength(100)
                .HasColumnName("DES_CHK_HECLI");

how can prevent to change column name?

1

There are 1 best solutions below

0
Farhad Azadaliyev On

Entity Framework by default uses column name with underscore for relational tables. For example CategoryId in Products table will be named as Category_ID. Maybe you can use [Column("DES_CHK_HECLI")] attribute upper of your property. Then add migration again. I hope it will help.