title: Sequence contains more than one matching element - Adding item with Entiity Framework
body: <p>I've googled this and don't get any answers for my particular circumstance.</p>
  
  <p><img src="https://i.stack.imgur.com/jlYpw.jpg" alt="This shows the exceptions i&#39;m getting."></p>
  
  <p>Im using Entity Framework in a suposedly simple way. I'm trying to add a record to the Memberproduct table. However I'm getting an exception that doesn't make sense.</p>
  
  <p>Any ideas what's wrong here?</p>
  
  <p><strong>MemberProduct Class:</strong></p>
  
  <pre><code>public class MemberProduct :ISaleable
  {
      public void ProcessSale()
      {
          throw new NotImplementedException();
      }
  
      private int id { get; set; }
      private string productName { get; set; }
      private decimal price { get; set; }
      private TaxClass taxClass { get; set; }
      private int quantity { get; set; }
      private Member memberAssociation { get; set; }
  
      public TaxClass TaxClass
      {
          get
          {
              return this.taxClass;
          }
          set
          {
              this.taxClass = value;
          }
      }
      public int Quantity
      {
          get
          {
              return this.quantity;
          }
          set
          {
              this.quantity = value;
          }
      }
      public string ProductName
      {
          get
          {
              return this.productName;
          }
          set
          {
              this.productName = value;
          }
      }
      public decimal Price
      {
          get
          {
              return this.price;
          }
          set
          {
              this.price = value;
          }
      }
      public Member MemberAssociation
      {
          get
          {
              return this.memberAssociation;
          }
          set
          {
              this.memberAssociation = value;
          }
      }
      public int ID
      {
          get
          {
              return this.id;
          }
          set
          {
              this.id = value;
          }
      }
  }
  </code></pre>
  
  <p><strong>Stack Trace:</strong></p>
  
  <pre><code>     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
     at System.Data.Entity.ModelConfiguration.Conventions.IdKeyDiscoveryConvention.IdKeyDiscoveryConventionImpl.MatchKeyProperty(EdmEntityType entityType, IEnumerable`1 primitiveProperties)
     at System.Data.Entity.ModelConfiguration.Conventions.KeyDiscoveryConvention.System.Data.Entity.ModelConfiguration.Conventions.IEdmConvention&lt;System.Data.Edm.EdmEntityType&gt;.Apply(EdmEntityType entityType, EdmModel model)
     at System.Data.Entity.ModelConfiguration.Conventions.IdKeyDiscoveryConvention.System.Data.Entity.ModelConfiguration.Conventions.IEdmConvention&lt;System.Data.Edm.EdmEntityType&gt;.Apply(EdmEntityType entityType, EdmModel model)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.EdmConventionDispatcher.Dispatch[TEdmDataModelItem](TEdmDataModelItem item)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.EdmConventionDispatcher.VisitEdmEntityType(EdmEntityType item)
     at System.Data.Edm.Internal.DataModelItemVisitor.VisitCollection[T](IEnumerable`1 collection, Action`1 visitMethod)
     at System.Data.Edm.Internal.EdmModelVisitor.VisitEntityTypes(EdmNamespace edmNamespace, IEnumerable`1 entityTypes)
     at System.Data.Edm.Internal.EdmModelVisitor.VisitEdmNamespace(EdmNamespace item)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.EdmConventionDispatcher.VisitEdmNamespace(EdmNamespace item)
     at System.Data.Edm.Internal.DataModelItemVisitor.VisitCollection[T](IEnumerable`1 collection, Action`1 visitMethod)
     at System.Data.Edm.Internal.EdmModelVisitor.VisitNamespaces(EdmModel model, IEnumerable`1 namespaces)
     at System.Data.Edm.Internal.EdmModelVisitor.VisitEdmModel(EdmModel item)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.EdmConventionDispatcher.VisitEdmModel(EdmModel item)
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.EdmConventionDispatcher.Dispatch()
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyModel(EdmModel model)
     at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
     at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
     at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
     at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
     at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
     at System.Data.Entity.Internal.InternalContext.Initialize()
     at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
     at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
     at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
     at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
     at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
     at System.Data.Entity.DbSet`1.Add(TEntity entity)
     at Nautix_EPOS.Controllers.HomeController.Index() in C:\sites\EPOS\Nautix EPOS\Nautix EPOS\Controllers\HomeController.cs:line 19
     at lambda_method(Closure , ControllerBase , Object[] )
     at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
     at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
     at System.Web.Mvc.ControllerActionInvoker.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;b__12()
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
  </code></pre>