views:

138

answers:

1

I'm using the following:

Fluently.Configure()
        .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString))
        .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Incident>()
        .Where(t => t.Namespace.StartsWith("EDA.DomainModel.POCO"))))
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();

It's essentially a copy of what's in the Fluent NHibernate wiki. However, whenever I run this line, it throws out this InnerException:

"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter."

I'm really not sure what the problem is, so I'm wondering if Fluent NHibernate can do automapping together with schema generation in the first place. What I want to do is just create a persistence layer for the POCO's without having to see the database or fool around with any tables whatsoever.

A: 

Yes it is possible. I use automapping and do export schema. As for that the exception I got it when I tried to map IDictionary<,>. Do you use it? Does Fluent NHibernate work at all - even if you don't try to export schema? I'd say that it's a problem with your mappings, not with schema export. If you have IDictionary then it's almost for sure. Try to nail down your schema to trivial classes and see if it helps; try to create database schema manually (for trivial classes it's simple) and check if it works then.

queen3
I removed the Dictionary and now it's saying that it can't find a mapping for my enums. Joy...
Daniel T.
I see what the problem is now, it can't handle collections of enums.
Daniel T.
I should be able to handle collection of enums, probably with a special custom user type, see http://stackoverflow.com/questions/439003/how-do-you-map-an-enum-as-an-int-value-with-fluent-nhibernate for example.
queen3
Oops, answering to you in both similar questions here ;-) Anyway, as I said there you probably need .AsElement().
queen3