简体   繁体   中英

Add custom static method to auto generated codes in EF6

How can I add a custom static method to auto generated codes in EF6? (using model.tt)

public partial class tbl_Persons
{
    public static void MyMethod(int personID)
    {
    //my codes
    }

    public tbl_Persons()
    {

    }

    public int ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string FatherName { get; set; }
}
  1. Read more about partial classes
  2. Create new file
  3. Place your code in this file:

     public partial class tbl_Persons { public static void MyMethod(int personID) { //my codes } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM