Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework .. partial constructor

I intend to extend the constructors of some of the entities in my Entity Framework (4).

However how do I ensure that my constructor is run after the model has run its. i.e. I want to ensure that the the object holds the data from the database before I work on it in my constructor.

like image 811
Adam Avatar asked Oct 15 '22 04:10

Adam


1 Answers

There is no generated constructor besides the default one; the objects are created via a factory method, and are simply initialized after construction.

You can write your own default constructor, and the generated code will call it before initializing all of the generated properties. If you write your own non-default constructor, you will also have to write your own default constructor, or else the designer file will not compile, since it assumes a default constructor exists.

like image 87
Dave Cousineau Avatar answered Oct 25 '22 02:10

Dave Cousineau