如何解决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固定相同的程序集。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。