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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:59:59+00:00 2026-06-14T20:59:59+00:00

I created a foreign key constraint between two of my SQL tables. Then I

  • 0

I created a foreign key constraint between two of my SQL tables. Then I went into the the project’s EDMX and selected “updated model from database”. However my diagram shows NO lines between the tables nor are there any navigation properties on them. The only reason I care about the lines is because the lines, the navigation property and the EF understood relationships are all somehow tied together; and I don’t want to screw with data integrity because EF had a different idea of the relationships.

Question: How does EF derive the navigation property from a database? If the state maintained inside SQL itself, what additional commands would I need to issue to the Azure SQL server to make it understand? Or do I have to modify the EDMX by hand?

Here is how I created the foreign key connecting the two tables

ALTER TABLE [dbo].[Employee]  
WITH CHECK ADD  CONSTRAINT [FK_Employee_Office_City] FOREIGN KEY([City])
REFERENCES [dbo].[Office] ([City])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Office_City]
GO

Important piece: The [City] column in the parent table (Office) isn’t a primary key – it is however a UNIQUE INDEX column.

Also, we used EF code first initially but switched to database-first as the project grew. We had to regenerated the EDMX completely off the database at that switching point. And because the older tables still have nice navigation properties (post EDMX regeneration), that state must be stored somehow in the database for EF to recreate them. Just don’t know how …

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

    It will not work because EF doesn’t understand unique keys. If you want to have mapped relationships the key in principal table must be primary key.

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

Sidebar

Related Questions

I have a problem creating a foreign key constraint between two tables. Here is
I created a table then added a foreign key reference to its primary key
I have two tables that I'd like to create a foreign key for. Primary
I'm having trouble figuring out how to create a foreign key constraint. My data
I have created a foreign key with NaviCat (a MySQL application), but the instant
is it valid for a foreign key to be null? i just created a
I am trying to create a series of tables with multiple foreign key relationships.
Here is my sql: CREATE TABLE companyprinciple { userid INT, FOREIGN KEY (userid) REFERENCES
I am trying to set a foreign key relationship between an Order_Items table and
Well, i have two tables publica_evento_grupo Field | Type | Null | Key |

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.