When I put on the client´s account, and click to save, show a message. Here´s what is showing: HttpPost, set USUARIO > An item with the same key has already been added. But it doesn´t happen when I save in the product sector.
I don´t know what to do, could someone explain to me? I´ll send some examples about the codes that was supposed to work in the website.
System.ArgumentException: Já foi adicionado um item com a mesma chave.
em System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
em System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) em System.Collections.Generic.CollectionExtensions.ToDictionaryFast[TKey,TValue](TValue[] array, Func
2 keySelector, IEqualityComparer1 comparer) em System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() em System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) em System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) em System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) em System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) em System.Web.Mvc.DefaultModelBinder.GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder) em System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) em System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) em System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) em System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) em System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) em System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) em System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.b__0(AsyncCallback asyncCallback, Object asyncState) em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase
1.Begin(AsyncCallback callback, Object state, Int32 timeout)
em System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)
em System.Web.Mvc.Controller.<>c.b__152_0(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState)
em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase
1.Begin(AsyncCallback callback, Object state, Int32 timeout)
em System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)
em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) em System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) em System.Web.Mvc.MvcHandler.<>c.b__20_0(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid
1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
em System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
em System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
em System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
em System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
C# 7.0
NET Framework – 4.8.1
EntityFramework – 6.4.4
EntityFramework.SqlServer – 6.4.4
EntityFramework.Firebird – 5.12.1
EntityFramework.6.4.4libnet45.dll
EntityFramework.Firebird.5.12.1libnet452.dll
EntityFramework.6.4.4libnet45EntityFramework.SqlServer.dll
public partial class PRODUTOS : IIDGenerator, ICreateID
public partial class USUARIOS : INewRecordData, IIDGenerator, ICreateID
public partial class CLIENTES : INewRecordData, IIDGenerator, ICreateID
Please, show me what codes are right and what codes are wrong. I believe that the product ones are right and the client are wrong. Even both being similars
[HttpPost]
[McMenu(Description = "Edição de registro",
LargeDescription = "Tela para a edição do registro apontado no banco de dados.")]
public virtual ActionResult Edit(T data, string HowToSave)
{
if (HowToSave.IndexOf("/") != -1)
return RedirectToAction("Index");
Product´s code, correct
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("LIVRO")]
[UIHint("IntTemplate")]
[Display(Name = "Cód. Prod.")]
public int PRODUTO { get; set; }
Client´s code, wrong
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[UIHint("IntTemplate")]
[Display(Name = "ID Usuário")]
public int USUARIO { get; set; }
Entrada: percorrendo a propriedade ‘McSoft.Dados.Modelos.CF.USUARIOS.set_USUARIO’.
Para entrar em propriedades ou operadores, acesse Ferramentas->Opções->Depuração e desmarque ‘Passar por propriedades e operadores (Somente gerenciados)’.
Entrada: percorrendo a propriedade ‘McSoft.Dados.Modelos.CF.USUARIOS.get_NOME_USUARIO’.
Para entrar em propriedades ou operadores, acesse Ferramentas->Opções->Depuração e desmarque ‘Passar por propriedades e operadores (Somente gerenciados)’.
Entrada: percorrendo a propriedade ‘McSoft.Dados.Modelos.CF.CLIENTES.get_CLIENTE’.
Para entrar em propriedades ou operadores, acesse Ferramentas->Opções->Depuração e desmarque ‘Passar por propriedades e operadores (Somente gerenciados)’.
Marco de Castro
I tried change the codes, and with that action I thought it could solve my problem.
Marco de Castro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.