I using Repository pattern and throw this exception.
Multiple object sets per type are not supported. The object sets 'Policyes' and 'Policies' can both contain instances of type 'VAgents.Web.Models.Policy
public class Policy
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime CreationTime { get; set; }
public string Description { get; set; }
}
Repository:
public IRepository<Policy> Policyes
{
get
{
return this.GetRepository<Policy>();
}
}
Interface class
IRepository<Policy> Policyes { get; }
public class BaseController : Controller
{
protected ITicketSystemData Data { get; private set; }
protected ApplicationUser UserProfile { get; private set; }
public BaseController(ITicketSystemData data)
{
this.Data = data;
}
protected override IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)
{
if(requestContext.HttpContext.User.Identity.IsAuthenticated)
{
this.UserProfile = this.Data.Users.All()
.Where(u => u.UserName == requestContext.HttpContext.User.Identity.Name)
.FirstOrDefault();
}
return base.BeginExecute(requestContext, callback, state);
}
}
And controller:
public class PolicyController : BaseController
{
ITicketSystemData Data;
public PolicyController(ITicketSystemData data) : base(data)
{
this.Data = data;
}
public ActionResult Index()
{
var getAllPolicy = this.Data.Policyes.All().Select(x=> new ListPolicyViewModel
{
Id = x.Id,
Name = x.Name
})
.ToList();
return View(getAllPolicy);
}
How to fix this exception!? Thanks :)