English 中文(简体)
资格包含不止一个配对要素——将项目与《Entiity Framework》合并。
原标题:Sequence contains more than one matching element - Adding item with Entiity Framework

我夸大了这一点,没有回答我的具体情况。

“这显示出例外情况:i

采用实体框架,可能简单。 我试图在会员国产品表中增加一个记录。 然而,我只想到一个没有意义的例外。

这里有什么错误的想法?

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;
        }
    }
}

www.un.org/Depts/DGACM/index_spanish.htm 标记:

     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<System.Data.Edm.EdmEntityType>.Apply(EdmEntityType entityType, EdmModel model)
   at System.Data.Entity.ModelConfiguration.Conventions.IdKeyDiscoveryConvention.System.Data.Entity.ModelConfiguration.Conventions.IEdmConvention<System.Data.Edm.EdmEntityType>.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:sitesEPOSNautix EPOSNautix EPOSControllersHomeController.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.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
最佳回答

我可以再次提出这个问题。 www.un.org/Depts/DGACM/index_spanish.htm

public class MemberProduct
{
    public int Id { get; set; }

    public int ID { get; set; }
}

EF代码在绘制地图时首先使用公约。 其中一项公约是处理名称为Id的特性。 Id (如果您不使用<代码>) 关键属性或定制图谱,因为它对财产名称作比较的情况并不敏感。

搬走其中一种财产,它应当发挥作用。

问题回答

如果对任何人有任何用处:

我在从存储程序中用EF收集模型时收到了这一错误。 储存的程序分多个栏目,其中两个栏目与名称相同。

我怀疑欧安会受到两种身份识别特性的混淆。

将私人财产改变到田里;这应当加以固定。

在建立实体国家时,在最初的种子时,我发现这种顺序错误。 有理由确保你正确确定物体图表的状况。 我的问题是原始数据(不是在实际应用期间)。 如果在管理移民最新数据库时能够帮助任何人,如果他们重犯顺序错误(如“历史包含不止一个配对要素”),那么,我就回答了。 虽然你在种子方法之外重新发现这一错误,但我认为,你的答复可能在于实体国家,其目标图表是正确的。

《实体框架法》

帮助正确确定实体物体图表,见以下博客员额,这是我在正确确定物体时发现的最佳人选:

http://blog.longle.net/05/11/genericizing-the-unit-of-work-pattern-repository- with-entity-framework-in-mvc/





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签