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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:02:12+00:00 2026-05-26T12:02:12+00:00

I have a convention for my ids, which automatically maps properties with a name

  • 0

I have a convention for my ids, which automatically maps properties with a name of Id as the identifier. As requirements are being fleshed out I need to tweak a domain model so naturally I went online and found that I need to create a class that inherits from IAutoMappingOverride<T>.

My convention:

public class PrimaryKeyConvention : IIdConvention, IIdConventionAcceptance
{
    public void Apply(IIdentityInstance instance)
    {
        instance.Column("Id");
        instance.GeneratedBy.SeqHiLo(instance.Name, "10");
    }

    public void Accept(IAcceptanceCriteria<IIdentityInspector> criteria)
    {
        criteria.Expect(x => x.Generator, Is.Not.Set);
    }
}

My override:

public class LocateMappingOverride : IAutoMappingOverride<Locate>
{
    public void Override(AutoMapping<Locate> mapping)
    {
        mapping.Map(x => x.SendTo).Not.Nullable();
    }
}

The convention does work as expected if I remove my override.

The exception I get is The entity 'LocateMappingOverride' doesn't have an Id mapped. Use the Id method to map your identity property. For example: Id(x => x.Id)..

Is it possible to use conventions in conjunction with mapping overrides?

  • 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-26T12:02:12+00:00Added an answer on May 26, 2026 at 12:02 pm

    The answer is – yes, automapping can work with overrides.

    Look what the error said. The problem is not with Locate entity, but with LocateMappingOverride entity, and that class should not be treated as entity, of course. You must have IAutomappingConfiguration configured so that FluentNHibernate’s rule what to treat as entity includes LocateMappingOverride, too. And it does not have an Id mapped, indeed.

    You should either:

    • change your IAutomappingConfiguration so that classes that implements IAutoMappingOverride<> are excluded
    • move the override outside the scope that is searched for entities
    • or introduce a common marker interface that all entities need to implement, i.e. IEntity and change IAutomappingConfiguration rules respectively.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database schema where the convention for a foreign key's name is:
I have an SQLite database from which I need to delete records periodically. What
You can have different naming convention for class members, static objects, global objects, and
I have a doubt: - Is there any standard/convention that when should I use
I have got this code and I am trying to understand the convention followed,
Is there a convention for naming the private method that I have called _Add
I have many js files, with some naming convention. If there any tool that
In our dev group we have a raging debate regarding the naming convention for
If I have user id variable, what is correct java naming convention for it?
Is there a convention for naming private functions in bash? I have a bash

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.