Entity Framework generates a code file for my database .edmx
, it creates for each entity .. If I customize some properties (change column names, makes required properties ... etc) as example I have the following class that generated by EF and I added some codes for it :
public partial class person
{
public int Id { get; set; }
public string FullName { get; set; }
[Required(ErrorMessage = "Mother name is required!")]
[Column("Mother Name")]
public string MotherName { get; set; }
}
Each time I made changes on database and generate .edmx file again, all changes that I made are gone (as commented at the top of the file.)
I can add some new properties by adding a partial class as this solution says but I can't add a partial class that contain the same property.
My question is: How can I separate my custom code from .edmx
to another file?