I see this IDbContext :
See this link. And then you will create a new partial class for the Entities Context With That interface.
public partial class YourModelEntities : DbContext, IDbContext
Editorial: I edited this post, This Works for me. My context
namespace dao { public interface ContextI : IDisposable { DbSet<TEntity> Set<TEntity>() where TEntity : class; DbSet Set(Type entityType); int SaveChanges(); IEnumerable<DbEntityValidationResult> GetValidationErrors(); DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity:class; DbEntityEntry Entry(object entity); string ConnectionString { get; set; } bool AutoDetectChangedEnabled { get; set; } void ExecuteSqlCommand(string p, params object[] o); void ExecuteSqlCommand(string p); } }
YourModelEntities is your automatically generated partial class, and you need to create a new partial class with the same name and then add a new context interface, for this example ContextI
NOTE. The interface did not implement all the methods, because the methods are implemented in your automatic code generation.
namespace dao { public partial class YourModelEntities :DbContext, ContextI { public string ConnectionString { get { return this.Database.Connection.ConnectionString; } set { this.Database.Connection.ConnectionString = value; } } bool AutoDetectChangedEnabled { get { return true; } set { throw new NotImplementedException(); } } public void ExecuteSqlCommand(string p,params object[] os) { this.Database.ExecuteSqlCommand(p, os); } public void ExecuteSqlCommand(string p) { this.Database.ExecuteSqlCommand(p); } bool ContextI.AutoDetectChangedEnabled { get { return this.Configuration.AutoDetectChangesEnabled; } set { this.Configuration.AutoDetectChangesEnabled = value; } } } }
user1626116 Nov 26 '13 at 21:49 2013-11-26 21:49
source share