mvc-mini-profiler,实体框架提供:空间\'SSpace\'没有关联的集合

问题描述

| 我正在尝试在我的mvc应用程序中使用mvc-mini-profiler。我为上下文创建了一个包装器,Castle Windsor创建了实例。但是,出现错误“空间'sspace \'没有关联的集合\”。 edmx在程序集A中,DigidosEntities在程序集B中,而这在程序集C中。您知道可能是什么问题吗?我获得了最新版本的探查器。
public interface IDataStore : Idisposable
{
    int SaveChanges(int personId);
    IObjectSet<TEntity> CreateObjectSet<TEntity>() where TEntity : class;
}
public class ProfiledDigidosEntities : IDataStore,Idisposable
{
    private DigidosEntities _context = null;
    public ProfiledDigidosEntities()
    {
        var connectionString = ConfigurationManager.ConnectionStrings[\"DigidosEntities\"].ConnectionString;
        var connection = new EntityConnection(connectionString);
        var conn = ProfiledDbConnection.Get(connection);
        _context = ObjectContextUtils.CreateObjectContext<DigidosEntities>(conn);  /* Error: The space \'sspace\' has no associated collection */
    }
    public void dispose()
    {
        if (_context != null)
            _context.dispose();
    }
    public int SaveChanges(int personId)
    {
        return _context.SaveChanges(personId);
    }
    public IObjectSet<TEntity> CreateObjectSet<TEntity>() where TEntity : class
    {
        return _context.CreateObjectSet<TEntity>();
    }
}
    

解决方法

        好的,这是我的问题:探查器希望工作空间进行新的探查连接,该工作空间是通过以下方法创建的(在ObjectContextUtils.cs中):
   static MetadataCache()
    {
        workspace  = new System.Data.Metadata.Edm.MetadataWorkspace(
          new string[] { \"res://*/\" },new Assembly[] { typeof(U).Assembly });
    }
如您所见,它将在要创建的类型的程序集中搜索。由于在我的情况下,模型的类型不在同一程序集中,因此创建工作区失败。将DigidosEntities移动到与edmx固定相同的程序集。