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

  • SEARCH
  • Home
  • 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 3981086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:22:06+00:00 2026-05-20T05:22:06+00:00

I am using Entity Framework 4.0, C# 4.0, .Net 2010 and SQL Server 2008

  • 0

I am using Entity Framework 4.0, C# 4.0, .Net 2010 and SQL Server 2008 R2. I have created the following view in my SQL Server database:

create view viewGetMember 
as 
    select distinct
        row_number() over (order by member.Membership_Number) ID,
        email.Communication_Point_Id id1,
        member.Membership_Number Number,
        dvt.Default_Name ParticipationStatus,
        person.Given_Name GivenName,
        person.Last_Name LastName,
        adrs.House_Number HouseNumber,
        adrs.Street Street,
        adrs.Post_Code PostCode,
        email.Email_Address EmailAddress
    from 
        Participation member
    inner join 
        Party_Participation pp on member.Participation_Id = pp.Participation_Id
    inner join 
        Party party on pp.Party_Id = party.Party_Id
    inner join 
        Individual person on party.Party_Id = person.Party_Id
    inner join 
        Domain_Value_t9n dvt on member.Participation_Status = dvt.Domain_Value_Id
    inner join 
        Communication_Point cpadrs on party.Party_Id = cpadrs.Party_Id 
    inner join 
        Communication_Point cpemail on party.Party_Id = cpemail.Party_Id
    inner join 
        [Address] adrs on cpadrs.Communication_Point_Id = adrs.Communication_Point_Id
    inner join 
        Email email on cpemail.Communication_Point_Id = email.Communication_Point_Id
    where 
        member.Membership_Number is not null 
go

select * from viewGetMember

In want to add this view in entity framework. However it has contain no primary in it. Though following two fields can form a composite primary key (second and third columns).

  • email.Communication_Point_Id id1
  • member.Membership_Number Number

I don’t know how to add them as part of Entity Framework. Even I have tried adding row_number() (first column) as an additional column by thinking it will act as a kind of primary key but no use. Entity Framework designer is not adding this view in .edmx model file.

I have tried this by entirely removing the .edmx file and in new project only for Entity Framework but no luck. Could someone please provide me a solution to this problem.

  • 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-05-20T05:22:06+00:00Added an answer on May 20, 2026 at 5:22 am

    I found a perfect answer from the Entity Framework and Sql Server view question. According to the answer given to that question the above SQL Query (view without primary key) has to be changed like following.

    create view viewGetMember as 
    select distinct
    isnull(member.Membership_Number,-1) Number,
    dvt.Default_Name ParticipationStatus,
    person.Given_Name GivenName,
    person.Last_Name LastName,
    adrs.House_Number HouseNumber,
    adrs.Street Street,
    adrs.Post_Code PostCode,
    email.Email_Address EmailAddress
    from Participation member
    inner join Party_Participation pp on member.Participation_Id = pp.Participation_Id
    inner join Party party on pp.Party_Id = party.Party_Id
    inner join Individual person on party.Party_Id = person.Party_Id
    inner join Domain_Value_t9n dvt on member.Participation_Status = dvt.Domain_Value_Id
    inner join Communication_Point cpadrs on party.Party_Id = cpadrs.Party_Id 
    and cpadrs.Communication_Point_Type in 
    (select dv.Domain_Value_Id from Domain_Value dv where dv.Short_Code = 'ADDRESS') 
    inner join Communication_Point cpemail on party.Party_Id = cpemail.Party_Id 
    and cpemail.Communication_Point_Type in 
    (select dv.Domain_Value_Id from Domain_Value dv where dv.Short_Code = 'EMAIL') 
    inner join Address adrs on cpadrs.Communication_Point_Id = adrs.Communication_Point_Id
    inner join Email email on cpemail.Communication_Point_Id = email.Communication_Point_Id and cpemail.Is_Preferred = 1
    where 
    member.Membership_Number is not null
    go
    select * from viewGetMember
    go
    

    The thrid line isnull(member.Membership_Number,-1) Number makes that column as primary key and we can get rid of row_number() over (order by member.Membership_Number) ID or whatever we don’t want to be as part of primary key.

    This works well in my case.

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

Sidebar

Related Questions

I'm trying to setup the Entity Framework with SQL Server 2008. I'm using Guids
I'm wondering if using VS.Net 2010, I can have Entity Framework 3.5 code running
I have a problem with the following Linq query using Entity Framework: from o
Okay, so I'm doing my first foray into using the ADO.NET Entity Framework. My
I am using Entity Framework with my website. To improve performance, I have started
So, I am using the Linq entity framework. I have 2 entities: Content and
I have Visual Studio 2010 on Windows 7. My project is using the .net
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes
When using the Entity Framework, does ESQL perform better than Linq to Entities? I'd
We been having some discussions on approaches to using the entity framework at work

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.