Click here to Skip to main content
15,882,017 members
Articles / Programming Languages / C
Tip/Trick

Extension points for ADO.NET Entity Framework

Rate me:
Please Sign up or sign in to vote.
1.92/5 (6 votes)
31 Dec 2009CPOL1 min read 7.9K   2  
I explored a bit more on Entity framework,during last week of 2009 and here goes my observations on how to extend the Entity Framework functionality if you want to customize the normal/ideal flow of Entity framework execution engine.1) OnContextCreatedBy default a declaration of this...
I explored a bit more on Entity framework,during last week of 2009 and here goes my observations on how to extend the Entity Framework functionality if you want to customize the normal/ideal flow of Entity framework execution engine.

1) OnContextCreated

By default a declaration of this method will be there as a partial method in the generated code, and as the name suggest this will be invoked during the first time when the ObjectContext class gets created,Hence this is the right place if you want to execute some operation after the ObjectContext creation

2) On<property>Changing(value)

Again this is the partial method which will be executed when the value of the property of an EntityObject is getting materialized,Hence if you wanna to add some logic/validation when the object property is getting assigned this is the right place of choice for you

3) On<property>Changed

This is the other partial method which will be executed after the property value of an EntityObject is assigned,Hence after the assignement if you want to perform any operation here you can write..

Note : Both the On<property>Changing and and On<property>Changed will be executed every time when the EntityObject is getting materialized, So if you wanna to write performance intent code be aware of the side effects !

Happy programming and a very Happy new year

Regards,
-Vinayak

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect MindTree Ltd
India India
Motivated achiever who guides organizations in applying technology to business settings, provides added value, and creates project deliverables in a timely manner. An experienced Technical Consultant, have successfully led large project teams of more than 20 people from requirements gathering to implementation and support using C#, .NET ,ADO.NET, ADO.NET Entity Framework,ASP.NET,ASP.NET MVC, WCF and SQL Server.

Comments and Discussions

 
-- There are no messages in this forum --