Reputation: 18754
I have the following code which gives me a mapping exception with no persister error:
var sessionFactory = Fluently.Configure()
.Database(
OracleClientConfiguration.Oracle10.ConnectionString(
c => c.FromConnectionStringWithKey("Main.ConnectionString")))
.Mappings(x => x.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
{
using (var tx = session.BeginTransaction())
{
var card = new Card {CardType = "Test"};
session.Save(card);
tx.Commit();
}
}
I have three projects in my solution: MainApplication
, Entities
and EntityMappings
MainApp
has a reference to Entities
and EntityMappings
has a reference to Entities
I don't understand what I am doing wrong. Any ideas ?
EDIT:
The properties are public
The exact error message is : No persister for: TNT_DAL.EntityClasses.Card
Upvotes: 1
Views: 4365
Reputation: 1824
Make sure that your entity and mapping classes are public
. Properties for your entities i.e. database fields should be public virtual
.
Also try specifying the assembly of a mapping class instead of using GetExecutingAssembly()
, I do vaguely recall experiencing trouble with it when I tried setting up FNH for the first time.
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<CardMap>())
Upvotes: 2