Tuesday, November 15, 2011

Switching from full Entity Framework to POCO


A big challenge I had with moving from a full Entity Framework solution to adopting a POCO set was managing state. Since my project was working well and I went to POCO I starting picking up issues with data not saving.
A huge issue was logging into the webapp. Obviously the most important function. The application tracks the logged in user via a session token saved to the database. After many frustrating tests and a half solution I thought was working, I finally found the ObjectStateEntry wasn’t keeping track of the object. The changes I was making to the object properties didn’t notify the OSE because I was using POCO and didn’t have it set up.
Searching google for some time I ran into this article http://blogs.msdn.com/b/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx . Great article and I came up with an ugly, but working resolution of changing the state manually before saving. Is there a better way? Most likely, but this works and was speedy fix to get users logged into the system.

No comments:

Post a Comment