I was using EF4 and a piece of code I found to get the MaxLength
value from an entity like this:
public static int? GetMaxLength(string entityTy
It means that you have not only upgraded EF but you have also changes the API. There are two APIs - the core ObjectContext API and simplified DbContext API. Your code is dependent on ObjectContext API (the only API available in EF4) but EF5 uses DbContext API (added in separate EntityFramework.dll assembly since EF4.1). If you want to use new EF features and your previous code you should just upgrade to .NET 4.5.
If you also want to use a new API you will have to update a lot of your existing code but it is still possible to get ObjectContext
from DbContext
and make your method work again. You just need to use this snippet:
var objectContext = ((IObjectContextAdapter)context).ObjectContext;
and use objectContext
instead of context
in your code.