我正尝试在我的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>();
}
}发布于 2011-08-13 18:33:31
好的,这是我的问题:分析器想要一个工作区来建立一个新的分析连接,工作区是通过这个方法创建的(在ObjectContextUtils.cs中):
static MetadataCache()
{
workspace = new System.Data.Metadata.Edm.MetadataWorkspace(
new string[] { "res://*/" },
new Assembly[] { typeof(U).Assembly });
}如你所见,它将在你想要创建的类型的程序集中进行搜索。因为在我的例子中,模型的类型不在相同的程序集中,所以工作区的创建失败。将DigidosEntities移动到与edmx相同的程序集中可以修复它。
https://stackoverflow.com/questions/6342182
复制相似问题