I have the following scenario:
I am using EF with Repository pattern and Unit Of Work from here
Then I extended my partial class and have created a Finder class which have GetAll and other methods. You can this see below:

Below you can see that I am using a unit of work class with repositories of all classes to get the instance from the generic repository:

protected Repository<Category> _CategoryRepository;
public Repository<Category> CategoryRepository
{
get { return _CategoryRepository ?? (_CategoryRepository = new Repository<Category>(context)); }
}
So in this way I had different repositories and when getting an entity from db and updating it from a different context caused problems. So I used this method to use for context lifetime management. And it resolved that issue.
Now the problem I am facing is in the following code:
var cat = Instance.Category.GetSingle(c => c.CategoryID == 7);
var orignal = cat.CategoryName;
var expected = cat.CategoryName + " Test Catg Update";
cat.CategoryName = expected;
cat.Update(); //This doesn't actually update due to a validation in place (which is correct)
cat = Instance.Category.GetSingle(c => c.CategoryID == 7);
Assert.AreEqual(cat.CategoryName, expected);
When I use Update and I have some validators in it, and the Update fails (for example due to size of the string exceeds 15 characters). When I try to call GetSingle (2nd last line of above code) again, it brings me the same old record which is [cat.CategoryName + " Test Catg Update"]. Is this a normal way? If not how can this be fixed so I can reload the object from database.
Let me know if you need any other code or reference.
DbContextsays it's implementing them both, and some blogs consider rewrapping it into another implementation is just additional complexity. I wonder if there's a single right way of going about it. ...feel free to remove the EF tag from your question title, the tag already categorizes your question under "EF".