We are using the database first approach to creating our MVC models, which means the framework auto-generates a default constructor in the primary .cs
file. I have a couple default values that I'd like to set, however, and the problem is this framework generates a basic .cs file for this model each time the .edmx
is updated. Is there any way to either override this constructor in something like a partial class?
Example
public partial class Product
{
// The framework will create this constructor any time a change to
// the edmx file is made. This means any "custom" statements will
// be overridden and have to be re-entered
public Product()
{
this.PageToProduct = new HashSet<PageToProduct>();
this.ProductRates = new HashSet<ProductRates>();
this.ProductToRider = new HashSet<ProductToRider>();
}
}