mishrsud / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

The space 'SSpace' has no associated collection #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Also on stack overflow: http://stackoverflow.com/questions/6342182

I'm trying to use the mvc-mini-profiler in my mvc application. I created a 
wrapper for my context and Castle Windsor creates the instance. However, I get 
the error "The space 'SSpace' has no associated collection". The edmx is in 
assembly A, DigidosEntities in assembly B and this is in assembly C. Any idea 
what can be the problem? I got the latest version of the profiler.

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

Original issue reported on code.google.com by john.lan...@gmail.com on 14 Jun 2011 at 10:30

GoogleCodeExporter commented 8 years ago

Original comment by marc.gravell on 14 Jun 2011 at 10:42

GoogleCodeExporter commented 8 years ago
Ok, here was my problem: The profiler wants a workspace to make a new profiled 
connection, the  workspace is created through this method (in 
ObjectContextUtils.cs):

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

As you can see it will search in assembly of the type you want to create. Since 
in my case the type of the model was not in the same assembly, the creation of 
the workspace failed. Moving the DigidosEntities to the same assembly as the 
edmx fixed it.

Original comment by john.lan...@gmail.com on 13 Aug 2011 at 10:51

GoogleCodeExporter commented 8 years ago
assuming this is by design then ... 

Original comment by sam.saff...@gmail.com on 15 Aug 2011 at 1:06