Override Default Constructor of Partial Class with Another Partial Class

I had a similar problem, with my generated code being created by a DBML file (I’m using Linq-to-SQL classes).

In the generated class it calls a partial void called OnCreated() at the end of the constructor.

Long story short, if you want to keep the important constructor stuff the generated class does for you (which you probably should do), then in your partial class create the following:

partial void OnCreated()
{
    // Do the extra stuff here;
}

Leave a Comment