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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:59:12+00:00 2026-05-27T04:59:12+00:00

I have tried many different mapping configurations but continue to generate exceptions or create

  • 0

I have tried many different mapping configurations but continue to generate exceptions or create / update the wrong record.

Exceptions

  • Cannot insert explicit value for identity column in table
  • Cannot use identity column key generation with union-subclass mapping
  • null id generated for class XXX

When I have a map that does save I have the following problem

I have successfully inserted and updated records in the database but these records do not have the appropriate id. They all have 0 for an id and as such only update the same record over and over.

Problem I am trying to solve

I am attempting to SubclassMap the interface IRequest. This interface is used as a property on a separate class AbstractWorkflowRequestInformation. When saving the parent class I want to save the referenced IRequest in the appropriate sub-class table. This is my current mapping which generates the exception Cannot insert explicit value for identity column in table. I am sure I have something tweaked in the way I am mapping the relationship between these two classes. What am I doing wrong? My maps are below.

IRequestMap

public class IRequestMap : ClassMap<IRequest>
{
    public IRequestMap()
    {
        Id(x => x.WorkflowRequestInformation)
            .GeneratedBy.Foreign("AbstractWorkflowRequestInformation");
        UseUnionSubclassForInheritanceMapping();
    }
}

public class PlanRequestMap : SubclassMap<PlanRequest>
{
    public PlanRequestMap()
    {
        Table("plan_request");
        // specific to PlanRequest property mappings and references
    }
}

public class BnjRequestMap : SubclassMap<BnjRequest>
{
    public BnjRequestMap()
    {
        Table("scratchdb.guest.bnj_request");
        // specific to BnjRequest property mappings and references
    }
}

AbstractWorkflowRequestInformationMap

public class AbstractWorkflowRequestInformationMap :
    ClassMap<AbstractWorkflowRequestInformation>
{
    public AbstractWorkflowRequestInformationMap()
    {
        Table("workflow_request_information");
        Id(x => x.Id)
            .Column("workflow_request_information_id")
            .GeneratedBy.Identity();

        // more property mappings and references
        References(x => x.SuperDuperRequest, "workflow_request_information_id")
            .Class<IRequest>().Unique().Cascade.All();
        // more property mappings and references
    }
}
  • 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-27T04:59:13+00:00Added an answer on May 27, 2026 at 4:59 am

    The issue here was that my IRequest map was missing a constraining reference back to AbstractWorkflowRequestInformation. So by adding a WorkflowRequestInformation property and the constraint everything now works as I intended.

    public class IRequestMap : ClassMap<IRequest>
    {
        public IRequestMap()
        {
            // adding this fixed the problem
            HasOne(x => x.WorkflowRequestInformation).Constrained();
            // adding this fixed the problem
    
            Id(x => x.WorkflowRequestInformation)
                .GeneratedBy.Foreign("AbstractWorkflowRequestInformation");
            UseUnionSubclassForInheritanceMapping();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need help with this regex pattern. I have tried many different patterns but
This should be really simple, but I have tried many solutions posted on the
I have tried to find how to create DLL-s on linux using google, but
I have tried different examples to filter a gridview by dropdownlist, but is it
http://www.example.com/http://www.test.com I have tried many different methods using .htaccess with no luck. I need
I know this must be a trivial question, but I've tried many different ways,
I have asked this question so many times and have tried so many different
So I have been battling this issue for awhile now and tried many different
I've tried many different ways of accessing the name of an attribute, but just
Over the years, I have tried many times to find a good, easy to

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.