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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:22:48+00:00 2026-05-28T18:22:48+00:00

Here is my problem: Domain: I have following Entities: [Sensor] that can be positioned

  • 0

Here is my problem:

Domain: I have following Entities: [Sensor] that can be positioned at [Location]. It is a many-to-many relationship. I break it into two one-to-many to aggregate a [Position] of a [Sensor] at [Location]. Intermediate Entity is [SensorPosition].

Mapping for [SensorPosition] is as follows:

 CompositeId().KeyReference(sp => sp.Sensor).KeyReference(sp => sp.Location);
        References(sp => sp.Sensor).ForeignKey().Not.Nullable();
        References(sp => sp.Location).ForeignKey().Not.Nullable();
        Component(sp => sp.Position, p =>
                                         {
                                             p.Map(pos => pos.X);
                                             p.Map(pos => pos.Y);
                                             p.Map(pos => pos.Z);
                                         });

I’m using a CompositeId() to enforce constraint of only one [Sensor] at one [Location]. (Same [Sensor] can be at different [Location]s, it is a business logic twist)

My question is: Can I add a generated primary key (Id) to this? I’ve tried it, but with CompositeId() in the mapping it is not being generated. Or is there any other way to enforce this constraint fluently?

  • 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-28T18:22:49+00:00Added an answer on May 28, 2026 at 6:22 pm

    I would avoid using composite primary keys. Uniquenes can be enforced by this mapping:

    References(sp => sp.Sensor).UniqueKey("KeyName");
    References(sp => sp.Location).UniqueKey("KeyName");
    

    For more details see this question.

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

Sidebar

Related Questions

I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I've just started using Fluent NHibernate and have run into the following problem trying
So here is my problem. I want to redirect name.domain.com/trips/1 to domain.com?username=name&trip=1 using modrewrite.
Problem: to get the command working here. My domain is http://cs.edu.com/user/share_dir , but I
I have a problem here. My Zend_Forms do not render in view script. Via
I've got a problem here with an MSI deployment that I'm working on (using
I have an interesting problem here I've been trying to solve for the last
I am using Ubuntu 10.04. By following the tutorial here , I have created
If I have three entities, Project, ProjectRole and Person, where a Person can be
I have the following snippet of jQuery: $(elementId).prevAll().appendTo(prevDiv); It works but the problem is

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.