具有相同键的条目已经存在&QUOT

具有相同键的条目已经存在&QUOT

本文介绍了错误修改DAL,System.ArgumentException,"具有相同键的条目已经存在"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,林完全符合这个难住了。我可能没有足够的信息张贴在这里,但我甚至不知道从哪里开始寻找。
我试图从数据库更新模式在我DAL.edmx文件。我列入到wasnt之前包括了视野。我想提神,然后我试图重新命名在数据库中的视图,然后从DAL删除的视图,所以我可以重新添加。这两次我

OK, Im totally stumped with this one. I may not have enough info to post here, but I dont even know where to start looking.I'm trying to "Update Model from database" on my DAL.edmx file. I included a field to a view that wasnt included prior. I tried refreshing, and then I tried renaming the view in the database and deleting the view from the DAL so I could re-add it. Both times I got

其次,没有理由我尝试添加我的看法改名成DAL,得到了同样的异常。从手动删除DAL.tt没有帮助。用Google搜索的问题,只有2个非相关的结果。我不知道在哪里甚至开始寻找。

Next, for no reason I tried adding my renamed view into the DAL, got same exception. Manually deleting from DAL.tt does not help. Googled issue and only 2 non-relevant results. I dont know where to even start looking.

我没有写出来,但这里是观之源SQL(如果它帮助)。英孚难道不添加改名观点的事实暗示它可能与SQL?在SQL运行在mngmnt工作室罚款。

I didnt write it, but here is the source sql of the view (if it helps). The fact that EF wouldnt add the renamed view hints it might be with the SQL? The SQL runs fine in mngmnt studio.

SELECT     ID, IssueID, IssueTypeID, IssueText, IssueCreateDate, WeekendDate, CustomerName, Employee,
                  CONVERT(DECIMAL(6, 2), AdjustedTotalRHours, 101) AS AdjustedTotalRHours, AdjustedTotalOHours,
                  AdjustedTotalRHours + AdjustedTotalOHours AS Hours, InvoiceNumber, AdjustedInvoiceAmount,
                  COALESCE
                      ((SELECT     SUM(InvoiceAmount) AS Expr1
                          FROM         TrendingDataFinal AS I1
                          WHERE     (InvoiceNumber = T1.InvoiceNumber) AND (CompanyID = T1.CompanyID) AND
                                                (CalType = 'F') AND (Aident = T1.Aident)), 0) AS TotalInvoiceAmount, InvoiceDate,
                  ROUND(DATEDIFF(DAY, InvoiceDate, GETDATE()), 0) AS DaysOutstanding, Notes, Aident, EINC, IsClosed,
                  CompanyID,
                      (SELECT     COUNT(ne.EntryID) AS Expr1
                        FROM          Madison.Notes.Note AS n INNER JOIN
                                               Madison.Notes.NoteEntry AS ne ON n.NoteID = ne.NoteId
                        WHERE      (n.Key1 = T1.InvoiceNumber)) AS HasNotes, COALESCE
                      ((SELECT     TOP (1) CompanyName
                          FROM         ReportingCompanies AS I1
                          WHERE     (CompanyId = T1.CompanyID)), '') AS CompanyName, BranchName, PayStatus
FROM         BillMan_ReportStage AS T1

任何建议将是AP preciated。

Any suggestions would be appreciated.

更新:创建崭新的品牌与观点相同的SQL,用了同样的方法将它添加到DAL,同样的错误

UPDATE: Created brand spanking new view with same SQL, went to add it by same method to DAL, same error.

推荐答案

我不,知道这是否会帮助,因为我不知道足以令它的意义,但我碰巧看到部分类vw_BillingIssues.cs的确在其实有它的额外领域。我做了vw_BillingIssues一词的解决方案范围的搜索和添加的额外场任意列表或集合缺少它(pretty其他任何地方),重建解决方案,并成功!我没有注意到的地方它提到的视图的基础表没有定义主键,但不记得在那里我看到了。

I dont know if this will help, because I dont know enough to make sense of it, but I happened to see that the partial class vw_BillingIssues.cs did in fact have the extra field in it. I did a solution-wide search for the term "vw_BillingIssues" and added the extra field to any list or collection that was missing it (pretty much everywhere else), rebuilt the solution and Success! I did notice somewhere it mentioned the underlying tables of the view did not have a primary key defined, but dont remember where I saw that.

这篇关于错误修改DAL,System.ArgumentException,"具有相同键的条目已经存在"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 16:29