Could not find entity named: Orchard.Core.Common.Models.CommonPartRecord

Topics: Writing modules
Nov 16, 2012 at 5:30 PM

I'm new to Orchard - learning it as I migrate an existing MVC application into a module.  I'm currently encountering an error which I believe is due to my module using Linq to SQL internally.  Long term it will migrate to NHibernate...  Is there something I need to be aware of when using a Data Context from SQL metal?

 

My error:

Could not find entity named: Orchard.Core.Common.Models.CommonPartRecord

[InvalidOperationException: Could not find entity named: Orchard.Core.Common.Models.CommonPartRecord]
   NHibernate.Linq.Util.CriteriaUtil.GetRootType(CriteriaImpl criteria) +226
   NHibernate.Linq.Visitors.MemberNameVisitor.IsRootEntity(EntityExpression expr) +216
   NHibernate.Linq.Visitors.MemberNameVisitor.VisitEntity(EntityExpression expr) +94
   NHibernate.Linq.Visitors.MemberNameVisitor.VisitPropertyAccess(PropertyAccessExpression expr) +37
   NHibernate.Linq.Visitors.WhereArgumentsVisitor.GetCollectionContainsCriteria(Expression list, Expression containedExpr) +101
   NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitMethodCall(MethodCallExpression expr) +633
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +456
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitLambda(LambdaExpression lambda) +32
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +504
   NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitUnary(UnaryExpression expr) +53
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +129
   NHibernate.Linq.Visitors.RootVisitor.HandleWhereCall(MethodCallExpression call) +113
   NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr) +992
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +456
   NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate(Expression expression, QueryOptions queryOptions) +119
   Orchard.ContentManagement.DefaultContentQuery.Where(Expression`1 predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:89
   Orchard.ContentManagement.ContentQuery`1.Orchard.ContentManagement.IContentQuery<T>.Where(Expression`1 predicate) in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:209
   Orchard.Widgets.Services.WidgetsService.GetWidgets(Int32[] layerIds) +560
   Orchard.Widgets.Filters.WidgetFilter.OnResultExecuting(ResultExecutingContext filterContext) +2106
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +70
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +853420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +853420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +853472
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:162
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Nov 16, 2012 at 5:35 PM

Its always right after a post the problem is solved... 

Turns out the issue was one of my assemblies was named "Common".  I moved it to a new assembly name and the above error is resolved.