I got this error when I go to submit the object from a list in MVC 5, and it is always happening in the second item of list
I use this to call the database method;
foreach (var modulo in _Modulos)
{
USERS_MODULO _modulo = new USERS_MODULO();
_modulo = modulo;
_modulo.USUARIO = usuario;
_PermissoesLinxDB.SalvaModulosUser(_modulo);
_modulo = null;
}
Line 86: { Line 87: DBRetaguardDataContext dbRetaguard = new DBRetaguardDataContext(); Line 88:
dbRetaguard.USERS_MODULOs.InsertOnSubmit(modulo); Line 89:
try Line 90: {Source File: c:\SOURCESAFE\Projetos\EMS\EMS.Dados\Controles\PermissoesLinxDB.cs
Line: 88Stack Trace:
[NotSupportedException: An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext. This is not supported.]
System.Data.Linq.StandardChangeTracker.Track(MetaType mt, Object obj, Dictionary2 visited, Boolean recurse, Int32 level) +891018
1.InsertOnSubmit(TEntity entity) +172
System.Data.Linq.StandardChangeTracker.Track(Object obj, Boolean recurse) +83 System.Data.Linq.StandardChangeTracker.Track(Object obj) +12 System.Data.Linq.Table