You are not telling Fluent NHibernate to use your class maps. The
AddAssembly method on NHibernate.Cfg.Configuration is for adding embedded
hbml xml configuration files, not class maps.

For more information on getting started with Fluent NHibernate see:
http://wiki.fluentnhibernate.org/show/GettingStarted%3A+First+Project

On Tue, Apr 7, 2009 at 12:25 PM, MalcolmS <[email protected]> wrote:

>
> Hi,
>
> I am writing an app using FluentNHibernate.
>
> To start with I am trying to run a test where I insert a row into my
> db table.
>
> My entities are in a seperate project (OurRecipes.Domain) and my
> mappings ie ClassMap<entity> classes are in a folder in this project.
>
> In my test project I have the configuration of NHibernate in the
> App.Config.
>
> This is how how I am creating my ISessionFactory
>
> namespace OurRecipes
> {
>    public class SessionFactoryCreator
>    {
>        public static ISessionFactory Create()
>        {
>            Configuration cfg = new Configuration()
>                .AddAssembly(typeof(SessionFactoryCreator).Assembly)
>                .AddAssembly(typeof(Recipe).Assembly);
>
>            return cfg.BuildSessionFactory();
>        }
>    }
> }
>
>
> It seems to me that this code is doing nothing and not loading the
> mappings at all. Recipe is in my entity project with the mappings and
> SessionFactoryCreator is in my tes project with App.Config.
>
> Any ideas why I get this error please?
>
>
> This is my test method
>
> public void CanAddRecipeToDatabase()
>        {
>            using (var session = _factory.OpenSession())
>            {
>                Recipe recipe = new Recipe();
>
>                recipe.RecipeTitle = "Chicken Curry";
>                recipe.PrepTime = 10;
>                recipe.CookTime = 20;
>                recipe.Method = "Cook chicken till tender.Serve with
> rice.";
>                recipe.ModifiedOn = DateTime.Now;
>
>                session.SaveOrUpdate(recipe);
>
>                var recipeid = recipe.RecipeID;
>
>                var recipe2 = session.Load<Recipe>(recipeid);
>
>                Assert.AreEqual(recipeid, recipe2.RecipeID);
>            }
>
>
> Malcolm
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to