Overriding ToString, Equals, .. in Entities when using the Entity Framework

I would like to override methods ToString, Equalsand GetHashCodeobject model generated by Entity Framework.

What could be the best way to do this?

Now I manually edit the file ___Model.Designer.csthat the model generates, but every time I change the model, of course, I lost these changes.

+5
source share
1 answer

Each object is defined as a partial class, so you can define an additional partial class to extend the object with additional properties or methods.

, Entity Person EntityModel.

Person.cs .

public partial class Person{
   // Here you can add your additional functionality or method overrides
}

, Person Entity.

- EntityModel ( Entity change, ).

+16

All Articles