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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:12:15+00:00 2026-05-22T02:12:15+00:00

I would like some assistance on how to troubleshoot a mappingexception that provides no

  • 0

I would like some assistance on how to troubleshoot a mappingexception that provides no detail. Er, OK — there’s plenty of detail just not a class or property.

For starters, I just upgraded to NH3.1 and FNH 1.2. I have an class that I use to build a SQLite database for NHibernate (3.1.0.4000). I am having trouble trying to isolate the fluent-nhibernate(1.2.0.712) mapping that is the problem.

The error is:

System.InvalidCastException: Unable to cast object of type 'NHibernate.Type.SerializableType' to type 'NHibernate.Type.IIdentifierType'.
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
NHibernate.MappingException: Bad identifier type: System.Guid
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
at NHibernate.Tuple.PropertyFactory.BuildIdentifierProperty(PersistentClass mappedEntity, IIdentifierGenerator generator)
at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory)
at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory)
at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)
at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at MYPROJ.DatabaseConfigurer.OpenSession(DbEnum database) in DatabaseConfigurer.cs: line 37
at MYPROJ.user_specification.<.ctor>b__5() in UserSpecs.cs: line 670

Guid? What Guid? I don’t have a Guid as an identifier anywhere in my mappings. I do have one Guid in a class as a property — I use the guid to batch records for processing by a service; not an identifier.

I get the error on this line where I instantiate an in-memory SQLiteConfiguration using fluent-nhibernate (1.2.0.712):

var sessionFactory = configuration.BuildSessionFactory();

I turned on log4net basic configuration to log to a file, but can’t find any errors. Here is the tail of that log:

2011-05-12 15:29:04,152 [1] ?.lambda_method(:0) - processing filters (second pass)
2011-05-12 15:29:04,199 [1] ?.lambda_method(:0) - Using dialect: NHibernate.Dialect.SQLiteDialect
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Using dialect defined converter
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Generate SQL with comments: disabled
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Configuring ConnectionProvider
2011-05-12 15:29:04,277 [1] ?.lambda_method(:0) - Transaction factory: NHibernate.Transaction.AdoNetWithDistributedTransactionFactory
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Optimize cache for minimal puts: False
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Connection release mode: on_close
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Default batch fetch size: 1
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - echoing all SQL to stdout
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Statistics: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Deleted entity synthetic identifier rollback: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Query language substitutions: {'true'='1', 'false'='0'}
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Wrap result sets: disabled
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Default entity-mode: Poco
2011-05-12 15:29:04,293 [1] ?.lambda_method(:0) - Named query checking : enabled
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - building session factory
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Session factory constructed with filter configurations : {}
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - instantiating session factory with properties: {'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'proxyfactory.factory_class'='NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle', 'connection.driver_class'='NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'dialect'='NHibernate.Dialect.SQLiteDialect, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'hibernate.dialect'='NHibernate.Dialect.SQLiteDialect, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'query.substitutions'='true=1;false=0', 'connection.release_mode'='on_close', 'show_sql'='true', 'connection.connection_string'='Data Source=:memory:;Version=3;New=True;'}
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Obtaining IDbConnection from Driver
2011-05-12 15:29:04,324 [1] ?.lambda_method(:0) - Closing connection

Log4net didn’t provide any insight, is there another way I can debug this exception to reveal maybe the class or property?

Thanks

EDIT
I use an IIdConvention for setting up my primary keys and ahem my pants are on fire: I use Elmah, which has a GUID for ErrorId. I will see if I can test the incoming instance in my convention for the proper UnsavedValue set for integers versus a Guid for Elmah. I will test this tomorrow and post the answer.

  • 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-22T02:12:15+00:00Added an answer on May 22, 2026 at 2:12 am

    I just removed the Elmah from test mapping and it builds fine now.

    Engine.UnsavedValueFactory.GetUnsavedIdentifierValue is throwing the error because 0 is not a valid default value for a GUID.

    I had a Fluent NHibernate ID convention that was previously setting all IDs with a default value of 0, and this broke with the change from 2.* to 3.1.0.4000.

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

Sidebar

Related Questions

I would like to ask for some assistance regarding OpenCV (I am currently a
Note: WinForms C# Early Learning Level! I would like some assistance with the best
I'm quite a novice with PHP, but would like some assistance with how to
I would like some help with the following regexes. 00 should be replaced by
I would like some advice on the best approach to use in the following
I would like some of my preferences to have icons, like the Settings app.
I am developing a site and i would like some simple markup. I would
I am learning C++ exceptions and I would like some clarification of the scenario:
I am designing RESTful Api's and would like some advice on designing an API
Ok, so I would like some advice on how to set up a model.

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.