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 8987565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:49:37+00:00 2026-06-15T21:49:37+00:00

I have a linked server on my SQL server that links to the Active

  • 0

I have a linked server on my SQL server that links to the Active Directory. I created a view that selects relevant information about the users from AD. This view does not have a primary key.
Now I want to build an OData service that will query the view from the browser and my application. I use .NET WCF Data services for that (.NET 4.0, VS2010). However, when I create an edmx file and I try to import the view, the view is not imported, because there is no PRIMARY KEY on it. I cannot create a primary key on a view (not possible on MS SQL Server), but I need it to be able to import the view in my Entity Data Model Designer. What can I do?
How can I make it work?

Let me add that I cannot create an indexed view, because my view is not schema bound (the data comes from Active Directory).

  • 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-15T21:49:38+00:00Added an answer on June 15, 2026 at 9:49 pm

    It’s really funny how you try to solve things for an hour or two, you decide to post on SO and solve your problem within minutes…

    I found this: https://stackoverflow.com/a/2715299/989256

    We had the same problem and this is the solution:
    To force entity framework to use a column as a primary key, use ISNULL.
    To force entity framework not to use a column as a primary key, use NULLIF.
    An easy way to apply this is to wrap the select statement of your view in another select.
    Example:

    SELECT
      ISNULL(MyPrimaryID,-999) MyPrimaryID,
      NULLIF(AnotherProperty,'') AnotherProperty
      FROM ( ... ) AS temp
    

    It worked just fine, but I am a little concerned about the performance. The view seems to load much slower…

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

Sidebar

Related Questions

I have a linked server on SQL Server that talks to Oracle. Executing the
I have a Microsoft Access form that is bound to a linked SQL Server
We have a linked server (in SQL Server) that connects to Sybase database. We
I linked my SQL Server 2008 to Active Directory like this: EXEC sp_addlinkedserver 'ADSI',
I have a SQL server instance that has a Linked server to an Oracle
I have created a view on a local server, that gets it's data from
I have a SQL stored proc that uses a linked server and Openquery to
I have linked the sql server tables to ms access so that I can
I have a SQL Server instance that I've added a linked server to another
I have a linked Firebird database on my SQL Server 2008 via ODBC. I

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.