How to map column and entity propery of different datatypes in entity framework code first

后端 未结 5 1247
北恋
北恋 2020-12-10 14:33

I am using Entity Framework 5 - Code first.

I have a database that I am connecting to that already exists for some time now (I did not create it). There is a table

5条回答
  •  伪装坚强ぢ
    2020-12-10 14:55

    Specify numeric type for column

    Property(x => x.Id).HasColumnName("Customer_id").HasColumnType("numeric");
    

    When generating database, it will create numeric column with precision 18,0. But when you are mapping to existing database, it will work fine with 5,0 numeric column.

提交回复
热议问题