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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:15:03+00:00 2026-05-25T03:15:03+00:00

Using Entity Designer in VS2010 to build a database for SQL Server 2005. Having

  • 0

Using Entity Designer in VS2010 to build a database for SQL Server 2005. Having a problem when I try to actually build the tables via the SQL generated by “generate database from model”; the tables are all created correctly, but it croaks on the foreign key constraints.

The entities at issue are laid out here:

World:
  WORLD_ID [int32] (Primary Key)
  Name [String]

Zone:
  WORLD_ID [int32] (Primary key, FK on World.WORLD_ID)
  ZONE_ID [int32] (Primary key)
  Name [String]

Region:
  WORLD_ID [int32] (Primary key, FK on Zone.WORLD_ID)
  ZONE_ID [int32] (Primary key, FK on Zone.ZONE_ID)
  REGION_ID [int32] (Primary key)
  Name [String]

This part of the generated SQL code is the problem:

-- Creating foreign key on [ZONE_ID], [WORLD_ID] in table 'Regions'
ALTER TABLE [dbo].[Regions]
ADD CONSTRAINT [FK_ZoneRegion]
    FOREIGN KEY ([ZONE_ID], [WORLD_ID])
    REFERENCES [dbo].[Zones]
        ([ZONE_ID], [WORLD_ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

The error is this:

There are no primary or candidate keys in the referenced table ‘dbo.Zone’
that match the referencing column list in the foreign key ‘FK_ZoneRegion’.

I have to assume the issue has something to do with the fact that, in my multi-column primary key (WORLD_ID+ZONE_ID+REGION_ID), both ZONE_ID and WORLD_ID are foreign keys, and specifically that WORLD_ID is actually also a foreign key in the table with the source for the FK.

Is there something wrong with my structure here? Is it not OK for me to just have a single association going from Zone -> Region, and in fact I have to have two associations, one from World -> Region and one from Zone -> Region?

Thanks,
-Dan

  • 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-25T03:15:03+00:00Added an answer on May 25, 2026 at 3:15 am

    For what it’s worth, I ended up just re-building the entity diagram from scratch, and it worked. No idea whether I had an error in my initial diagram, or whether this was a glitch with Entity Designer.

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

Sidebar

Related Questions

I'm using VS2008 (.NET 3.5) and Entity Framework over SQL Server. I'm hoping to
I am using Entity Framework 4.0, C# 4.0, .Net 2010 and SQL Server 2008
I'm using entity framework designer to build entities. I found the designer really hard
I'm using Entity Framework in my project, and I have the problem that, once
I am using Entity Framework 4 in a desktop application with SQL Compact. I
I have a problem with the following Linq query using Entity Framework: from o
I'm pretty new to MVC 2 using the Entity Framework. I have two tables
I created a model in the edm designer (VS10) using DbContext Entity Generator as
Using Microsoft's designer for the Entity Framework (v3.5), I have created an Entity Model
Using the designer in Visual Studio, how can you define an entity that maps

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.