Last Updated: February 25, 2016
·
2.774K
· neelamsk

Entity framework - beware of duplicate records

One thing I learnt while using entity framework is to always have a unique column in your select statement. Specially when you are using views in LINQ queries. Else you will end up having duplicate record for some weird reason.
Though your count will be the expected count of results, but there will be duplicate rows instead of uniques.
I ended up in a big mess because of this, I had to send an emailer where I used LINQ to fetch my record from SQL Sever View. I just had two columns in there - name,email - no unique ID!! There were duplicate records because of which some people got same mail 100 times!!!!!!!!!!!!!!!!!!!!!!.
So Beware!!!