Last post Feb 12, 2016 01:46 PM by Adam-M
Feb 12, 2016 09:22 AM|Adam-M|LINK
I'm using Entity Framework 6 and I'm trying to add SQL Server View to my entity model. I update model from database, then browse to add the view but it doesn't add it or error. I'm guessing it's something to do with a primary key but this is the view in
select ROW_NUMBER() OVER(order by c.ID) AS RowID
,(select count(ComponentID) from pod_components where ComponentID = c.id and PodID = pc.PodID) AS Qty
from pod_components pc
inner join components c on c.ID = pc.ComponentID
group by pc.[PodID], pc.[ComponentID], c.[ID],c.[Description],c.[CategoryID],c.[Vendor_SKU]
How can I include it in my model?
Thanks in advance
Feb 12, 2016 01:46 PM|Adam-M|LINK
I edited the first row to use ISNULL which forces EF6 to use that column as a key. NULLIS does the opposite.
select ISNULL( ROW_NUMBER() OVER(order by c.ID),-1 )AS RowID