Entity Framework tips

  • We mark a property as database generated so the application will not save any changes made to them. For ex: default value in db, key with auto increament

[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public string CreateUser { get; set; }

  • To generate fields change when update, instead of update all fields

aswigEntities.Entry(oldWca).CurrentValues.SetValues(newWca);

Advertisements