I wanted to use the first sample EF 4.1 code that could be tested per unit. I followed the sample code illustrated in the answer to This Post . But now I get the error message "Multiple sets of objects for each type are not supported." I also use the latest Structure Map for IoC. I am not sure how to solve this problem.
Many sets of objects for each type are not supported. Participant Types and Participant Types object sets can both contain instances of type 'SocialSite.Model.Entities.MemberType'.
Line 82: public virtual IEnumerable<T> FindAll()
Line 83: {
Line 84: return _dbSet.ToList();
Line 85: }
Line 86:
[InvalidOperationException: Multiple object sets per type are not supported. The object sets 'MemberTypes' and 'MemberTypes' can both contain instances of type 'SocialSite.Model.Entities.MemberType'.]
System.Data.Entity.Internal.DbSetDiscoveryService.RegisterSets(DbModelBuilder modelBuilder) +336
System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() +393
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +22
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +117
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +407
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +17
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +62
System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +40
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +315
System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
SocialSite.Data.Repositories.Impl.Repository`1.FindAll() in D:\Visual Studio 2010\SocialSite\SocialSite.Data\Repositories\Impl\Repository.cs:84
SocialSite.Service.Impl.MemberTypesService.GetMemberTypes() in D:\Visual Studio 2010\SocialSite\SocialSite.Components\Impl\MemberTypesService.cs:23
SocialSite.Web.Areas.Admin.Controllers.MemberTypesController.ListMemberTypes() in D:\Visual Studio 2010\SocialSite\SocialSite\Areas\Admin\Controllers\MemberTypesController.cs:44
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862381
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
not sure how to format the stack trace with any berterter than this.
, .
public class MemberType
{
[Key]
public virtual int Id { get; set; }
[StringLengthAttribute(65, ErrorMessage = "Maximum length 65 characters")]
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual bool Registration { get; set; }
public virtual bool Enabled { get; set; }
[TimestampAttribute]
public virtual byte[] Timestamp { get; set; }
public virtual bool Activation { get; set; }
public virtual Guid RoleId { get; set; }
public virtual bool Searchable { get; set; }
public virtual ICollection<MemberTypeProfileFieldGroup> MemberTypeProfileFieldGroups { get; set; }
}