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

  • Home
  • SEARCH
  • 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 4548822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:16:28+00:00 2026-05-21T16:16:28+00:00

This is a sample scenario. I have an existing database consisting of tables as

  • 0

This is a sample scenario. I have an existing database consisting of tables as below;

Orders, with field OrderId (PK, int)

Products, with fields ProductId (PK, int), PriceId (FK, int)

OrdersProducts, with fields OrderProductId (PK, int), OrderId (FK, int), ProductId (FK, int), OrderingStatus (int)

Price with field PriceId (PK, int)

All PKs are identity.

My Entities are;

public class Order
{
 [Key]
 public int OrderId { get; set; }
 public virtual IList<Product> Products { get; set; }
}

public class Product
{
 [Key]
 public int ProductId { get; set; }
 public string Name { get; set; }
 public int OrderingStatus { get; set; }

 public virtual Price Price { get; set;}

}

public class Price
{
 [Key]
 public int PriceId { get; set;}

}

And here are my mappings;
Order;

  HasMany<Product>(x => x.Products)
    .WithMany()
    .Map(m =>
    {
      m.MapLeftKey("OrderId");
      m.MapRightKey("ProductId");
      m.ToTable("OrdersProducts", "dbo");
    });

Product;

Map(m =>
  {
    m.Properties(p => new
    {
      p.Name
    });
    m.ToTable("Products", "dbo");
  });

  Map(m =>
  {
    m.Properties(p => new
    {
      p.OrderingStatus
    });

    m.ToTable("OrdersProducts", "dbo");
  });

  HasRequired<Price>(x => x.Price)
    .WithMany()
    .Map(m => m.MapKey("PriceId"));

Price;

  ToTable("Prices", "dbo");

I can’t get this right with my mappings in the context, is there anyone that can help me in the right direction.

I am actually having two kinds of trouble here, first the mapping of OrderingStatus to my intermediate table, second I have trouble connecting my tables, ie ‘Schema specified is not valid. Errors: … error 0019: Each property name in i a type must be unique. Property name ”OrdersProductsId” was already defined.’


  • 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-21T16:16:28+00:00Added an answer on May 21, 2026 at 4:16 pm

    Your mapping will not work – you can’t map OrderingStatus to your Prodcut because it is not in the same table and it is not related by one-to-one relation to the Product. It is in separate table with one-to-many relation. You must expose OrdersProducts as separate entity because your junction table contains additional properties which you want to use:

    public class Order
    {
        [Key]
        public int OrderId { get; set; }
        public virtual ICollection<ProductOrder> ProductOrders { get; set; }
    }
    
    public calss ProductOrder
    {
        [Key]
        public int OrderProductId { get; set; }
        public int OrderStatus { get; set; }
        public virtual Product { get; set; }
        public virtual Order { get; set; }
    }
    
    public class Product
    {
        [Key]
        public int ProductId { get; set; }
        public string Name { get; set; }
        public virtual Price Price { get; set;}
    }
    
    public class Price
    {
        [Key]
        public int PriceId { get; set;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a sample of the scenario I'm facing. Say I have this column family:
in this sample method/message: -(void) setNumerator:(int) n { numerator = n; } What does
Scenario: I have an application (C#) that expects a SQL database and login, which
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
I just found this post , we have almost the same scenario with the
I have two MySQL tables: house and features . This is for a real
This is a question for a WSS/SharePoint guru. Consider this scenario: I have an
I have a scenario where I am designing a system for a retailer. This
We have this common scenario where we have a method that performs some action
Can I get a complete simple scenario i.e. tutorial that suggest how this should

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.