I have an existing class Foo that I would like to persist "as is". By this, I mean not modifying how the class is implemented. Rather than a public vitual int Id property, Foo has a public int Id field. I had hoped to be able to map this using Id(x => x.Id).Acess.AsField(), but doing so results in an InvalidCastException.
Is there a way to use the public int Id as the mapped Id for a persistent object? Here's my code: public class Foo { public int Id; } public class FooMap : ClassMap<Foo> { public FooMap() { Id(x => x.Id).Access.AsField(); } } private static void BuildSchema(Configuration config) { new SchemaExport(config).Create(false, true); } var config = Fluently.Configure(). Database(SQLiteConfiguration.Standard.UsingFile(file).ShowSql()). Mappings(m => m.FluentMappings.AddFromAssemblyOf<Foo>()); config.ExposeConfiguration(BuildSchema); this.factory = config.BuildSessionFactory(); and here's the resulting exception: [nunit2] ----> FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. [nunit2] [nunit2] [nunit2] ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. [nunit2] ----> System.InvalidCastException : Cannot cast from source type to destination type. [nunit2] at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () [0x00000] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---