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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:42:12+00:00 2026-06-10T22:42:12+00:00

I need to create a composite key for a view in SQL Server 2008

  • 0

I need to create a composite key for a view in SQL Server 2008 because I cannot import a view into entity framework without a primary key defined and since Views don’t have primary keys I have to create. Right now I am getting this error when I try to import the View into EF.

The table/view ‘FanDB.dbo.Quick_View’ does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.

I have been able to add the View to EF before but my boss deleted our DB and so I am recreating the DB from scratch. I have just forgotten how I did it:( Thanks for your help, feel free to ask any questions I will be checking back as often as I can and if I figure it out I will post the solution because all the questions on stack overflow either say to edit the XML file(can’t do this because I can’t add it to the .edmx) or add a primary key column which I can’t do because it is a quick view.

  • 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-10T22:42:14+00:00Added an answer on June 10, 2026 at 10:42 pm

    You could recreate the view as a table, add a primary key, import it into EF, and then drop table and reinstate the view. This will get your table into EF, but then you have to be careful whenever you update the model again in the future.

    Alternatively, you could create a model db, with all the same object names as your actual db, but with views created as tables. At design time, use the model db, and at run time, use the actual db. So long as the view is updateable, the EF runtime won’t care that it’s actually a view, and not a table.

    If you are feeling compulsive, and have a lot a tables, it wouldn’t be too hard to auto-magically generate the model db from the actual db.

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

Sidebar

Related Questions

Using sql, i need to make Lineno and orderline into a composite key how
I use MS SQL 2008 R2, I need create a Table with a CHECK
I need to create a scrollable composite view on iOS. That is to say,
I'm trying to create a table in SQL Server 2000, that has a composite
Is it possible to create a composite key in sql 2000 code id abc
Is there a way to create a composite key in Hibernate, with annotations, without
I need create custom dialog and put JPanel into it. Is it possible?
Need to create a custom DNS name server using C which will check against
Original Question: Database Design: need composite key + foreign key Here's what I need:
I am am trying to construct a database in SQL Server 2008 R2 that

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.