How to set default values ​​in Entity Framework

I have a table with 52 columns in my database, and I want to write a function to create a row in this table.
In my case, I do not want to use all the columns in this table, so I created my model as follows.

[Table("CUST_MASTER")]
public class CustomerMaster
{
    [Key]
    [Column("CUSTOMER_ID")]
    public string Id { get; set; }

    [Column("CUSTOMER_NAME")]
    public string Name { get; set; }

    [Column("CUSTOMER_CITY")]
    public string City { get; set; }
 }

Is there a way to send only this data through the Entity infrastructure and set all other fields with invalid values ​​for some default data (for "" strings, for decimal places 0.0, etc.) without writing all these fields in my model and not doing it manually?

+3
source share
3 answers

, SQL.

, - .

+4

, , , .

0

, - , . . / .

Update: FWIW, this assumes this is already possible in scripts other than Code-First.

0
source

All Articles