2011-06-14 44 views
2

我試圖在我的mvc應用程序中使用mvc-mini-profiler。我爲我的上下文創建了一個包裝,Castle Windsor創建了這個實例。但是,我收到錯誤「空間」SSpace'沒有關聯的集合「。 edmx在彙編A中,彙編B中的DigidosEntities中,並且在彙編C中。任何想法可能是什麼問題?我收到了最新版本的分析器。mvc-mini-profiler,實體框架給出:空間'SSpace'沒有關聯的集合

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>(); 
    } 
} 
+0

你可以試試最新的? – 2011-07-19 08:08:20

回答

2

好吧,這裏是我的問題:探查想要一個工作空間,使新的​​異形連接,工作區通過這個方法(在ObjectContextUtils.cs)創建:

static MetadataCache() 
    { 
     workspace = new System.Data.Metadata.Edm.MetadataWorkspace(
      new string[] { "res://*/" }, 
      new Assembly[] { typeof(U).Assembly }); 
    } 

,你可以看到它會搜索你想創建的類型的程序集。因爲在我的情況下,模型的類型不在同一個程序集中,所以創建工作空間失敗。將DigidosEntities移動到與edmx相同的程序集中。