This is my first time using the Entity Framework and I'm getting some confusing results. I know a particular table contains 3 distinct rows when I run this SQL query:
SELECT * FROM mytable WHERE service_month = 201012
When I run this query against the framework however, I get 3 rows, but they are all copies of the first row (VB syntax).
Dim temp 开发者_StackOverflow中文版= _context.mytable.Where(Function(x) x.service_month = 201012)
Did I set up something incorrectly? This is how I'd do it with LINQ to SQL so I feel like I'm missing something.
Fix your primary key definition in your EDMX. (If your table has no PK, add one.) When all rows return the same "key", the EF returns the same object instance.
I experienced this in Code First 5.0.13 when I had used a [Key] attribute in the business object that came from the wrong library. It should be
System.ComponentModel.DataAnnotations.KeyAttribute
精彩评论