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
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.
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
Any suggestions would be appreciated.
UPDATE: Created brand spanking new view with same SQL, went to add it by same method to DAL, same error.
I had exactly the same issue. As i noticed, the issue appeared after merging of .edmx files with Subversion. Looking on .edmx file in text editor, i found one duplicated EntitySetMapping entry. After manually deleting the duplicate, the issue was solved! Hope this helps
remove/add was not suitable for my current project.
solved this problem with a one-time small program for finding duplicate mapping entries
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace EntityModelHelper
{
class Program
{
static void Main(string[] args)
{
// path to edmx file
var filesPath = @"SamePath\Model.edmx";
var lines = File.ReadAllLines(filesPath);
var searchNames = new List<string>();
foreach (var line in lines)
{
var searchString = "<EntitySetMapping Name=";
if (line.Contains(searchString))
{
var tmp = line.Substring(line.IndexOf(searchString) + searchString.Length+1);
var searchName = tmp.Substring(0, tmp.IndexOf("\""));
searchNames.Add(searchName);
}
}
foreach (var duplicateName in searchNames.GroupBy(x => x).Where(x => x.Count() > 1))
{
Console.WriteLine(duplicateName.First());
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With