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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:17:56+00:00 2026-05-28T17:17:56+00:00

With Entity Framework, whenever I update model from database inside Visual Studio the model

  • 0

With Entity Framework, whenever I “update model from database” inside Visual Studio the model that’s created isn’t usable.

The issue is that EF doesn’t handle tables without a primary key very well. It treats them as a view, which in turn prevents you from editing the table with EF. You can override this behavior by opening the model (edmx file) as an XML file and making a few changes to the EntitySet definition. It’s annoying to do this over and over. Has anyone found a more permanent workaround besides adding a primary key or modifying the edmx file after every update?

By the way, I am using a unique key but it’s spread across two columns. It’d be nice if EF could handle this, but as of EF 4.2 it doesn’t.

  • 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-28T17:17:57+00:00Added an answer on May 28, 2026 at 5:17 pm

    I don’t understand – you’re using a “unique key” (I assume you mean a unique index or a unique constraint) because the key has two columns? You can create a primary key with multiple columns. I’m not sure why EF would treat a two-column key differently than a single-column primary key, but here is a simple example of a multiple-column primary key:

    CREATE TABLE dbo.foobar
    (
        fooID INT,
        barID INT,
        PRIMARY KEY (fooID, barID)
    );
    

    Of course there is other syntax that allows you to create the constraint after the fact, and you should also name your constraint explicitly, but just wanted to show a simple example.

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

Sidebar

Related Questions

My Entity Framework model is generated from SQL Server database. Since I need to
I have a edmx file created using the entity entity framework model. Whenever I
I created an Entity Framework model based on an existing database, then generated the
I've built a entity framework model against a 2008 database. All works ok against
I am building an Entity Framework model for a subset of the Pubs database
I have an object defined by my entity framework model that has navigation properties,
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Entity framework provides great flexibility to update data in the same datacontext Dim personA
Entity Framework has created the required partial classes. I can add these partial classes
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes

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.