Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:51:36+00:00 2026-06-01T14:51:36+00:00

I am using EF4 to read data from a view .This is a summary

  • 0

I am using EF4 to read data from a view .This is a summary view with group by etc and is readonly-it does not have a primary key. So inorder to make it import into EF4 I used an often suggested trick -ie use ISNULL(column,-11) as the first column in the view. This helps EF4 to infer primary key and import the view.

However when I select from the view in EF4 very strange thing happens – I get incorrect data as compared to when I directly select from the view in Management studio. I could not believe this so I tried a few times and the error persisted. Just to make sure I created a table in SQL Server by select all from the view and accessed the table in EF4 .But then in returns correct data!

The view is not very complicated except that it is a summary view (group by with joints) and it uses a SQL Common table expression(ie the with clause).

When I select straight in database using select * from vw_responserate I get 

coltext       SurveyId  rowtext1    rowtext2            cnt
Anwender    2   Angestellte/r   Französische Schweiz    1
Anwender    2   Angestellte/r   Italienische Schweiz    1
IT Spezialist   2   Angestellte/r   Deutsche Schweiz    1
IT Spezialist   2   Mittleres Management / Senior Management    Italienische Schweiz    1

When I select from EF4 I get

coltext rowtext1 rowtext2 cnt
Anwender      Angestellte/r Französische Schweiz 1
Anwender      Angestellte/r Französische Schweiz 1
IT Spezialist Angestellte/r Deutsche Schweiz 1
IT Spezialist  Angestellte/r Deutsche Schweiz 1

Any help would be appreciated

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:51:38+00:00Added an answer on June 1, 2026 at 2:51 pm

    I had the same issue, the problem is that the key defined for the view does not uniquely identify a single row.

    Looking at the sample data, your problem should be solved by setting coltext, rowtext1 and rowtext2 as the key.

    This can be done through the designer by right clicking each property and selecting ‘Entity Key’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EF4 and Linq I have a data structure which looks like this: parentid
Using EF4 Codefirst RC and MVC .NET I have a Strongly typed view I
I am using EF4 with the EDM designer. I have two tables : Users
I've been using EF4 (not code-first) since a year, so I'm not really an
I am using EF4 + MVC 3 with Razor. I have the following ActionResult
I am using EF4 and I have a situation where I need to insert
New to Entity Framework .Using EF4. I have found articles and managed to use
I am using EF4 CPT4 Code first and I have setup my ObjectContext to
How can I retrieve Tuples at Select using EF4? var productCount = (from product
I have an MVC3 project that is using an EF4 project as its Domain.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.