Я получаю
На объектный объект нельзя ссылаться несколькими экземплярами IEntityChangeTracker
и я просто не понял, как ее решить, мне 5 часов пытались это исправить, кто-то, помогите мне, пожалуйста,
Вот мой контроллер:
private readonly IMovesService movesService;
private readonly IEffectsService effectsService;
public ToonMovesController()
{
movesService = new MovesService();
effectsService = new EffectsService();
}
Вот услуги:
//Moves Service Class
private readonly IRepositoryBase<ToonMoves> repositoryMoves;
public MovesService()
{
repositoryMoves = new RepositoryBase<ToonMoves>();
}
//Effects Service Class
private readonly IRepositoryBase<Effects> repositoryEffects;
public EffectsService()
{
repositoryEffects = new RepositoryBase<Effects>();
}
И RepositoryBase, которая получает сущность и экземпляр контекста БД
public Entities Context;
public RepositoryBase()
{
Context = new Entities();
}
И я получаю сообщение об ошибке при попытке сохранить объект сущности:
public ActionResult Create(ToonMoves toonMoves, HttpPostedFileBase imgMove, List<int> idsEffects)
{
toonMoves.Icon = new byte[imgMove.ContentLength];
imgMove.InputStream.Read(toonMoves.Icon, 0, imgMove.ContentLength);
if (ModelState.IsValid)
{
//For each id i add an effect on move entity object
if (idsEffects != null)
{
foreach (var item in idsEffects)
{
Effects ef = new Effects();
ef = effectsService.Get(item);
toonMoves.Effects.Add(ef);
}
}
//I get the error here when i try to save!
movesService.Save(toonMoves);
return RedirectToAction("Index");
}
return View(toonMoves);
}