I am generating entity framework classes from a SQL Server table. However I am not seeing the partial methods like the example below:
partial void OnFirstNameChanging(global::System.String value);
partial void OnFirstNameChanged();
I am using VS2012 & EF6.0. Many online examples talks about over-ridding these partial methods in newly created partial classes to put validation logic. But I can't find these methods in my auto-generated code. Is this something that's manually added in EF6.0? Will appreciate feedback. Thanks.
You are using wrong generator. Those methods are only generated by EntityObject
based generator (the one which is deprecated). Default generator uses POCO classes where these partial methods are not generated - you can modify the generator to add them (it is a T4 template).
To use EntityObject
generator:
Opening .tt file and searching for Changing and Changed words will give you and idea what is necessary to do in case of adding those methods to POCO generator.