Here is my CreateSessionFactory method it seems basically just like in the
example.
private static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c => c.Server("xxx")
.Database("xxx")
.Username("xxx")
.Password("xxx")))
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<LearnDomainModel.Entities.Word>()
.AddFromAssemblyOf<LearnDomainModel.Entities.WordType>())
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
}
On Sun, Jul 19, 2009 at 6:29 PM, James Gregory <[email protected]>wrote:
> Have you modified the CreateSessionFactory method? because that uses an in
> memory database, and recreates it on every run of the application.
>
>
> On Sun, Jul 19, 2009 at 11:57 PM, percent20 <[email protected]> wrote:
>
>>
>> Am still trying to figure out fluent NHibernate and NHibernate. What
>> I am trying to do right now is figure out how to do an insert and
>> insert more data like a normal insert.
>>
>> As it is right now I am running through the first example and goofing
>> around with it to get a feel for Fluent NHibernate, and am modifying
>> it here and there. Here is my main in program.
>>
>> static void Main(string[] args)
>> {
>> var sessionFactory = CreateSessionFactory();
>>
>> using (var session = sessionFactory.OpenSession())
>> {
>> using (var transaction = session.BeginTransaction())
>> {
>> var help = new Word { TheWord = "throw",
>> WordTypeID = new System.Guid("A2F85066-A296-4453-B9C3-
>> CB795E2CA95D") };
>>
>> session.Save(help);
>>
>> transaction.Commit();
>> }
>>
>> Console.ReadKey();
>> }
>> }
>>
>> Here is mapping for word
>>
>> public class WordMap : ClassMap<Word>
>> {
>> public WordMap()
>> {
>> WithTable("Words");
>> Id(x => x.ID, "GUID").GeneratedBy.Guid();
>> Map(x => x.TheWord, "word");
>> Map(x => x.WordTypeID, "WordTypeGUID");
>> }
>> }
>>
>> Basically ever time I run the app it just updates the current values
>> instead of inserting new values into it. Been googling for a while
>> but just not understanding. I am not sure if it is a hibernate or
>> fluent hibernate
>>
>> For a couple of other questions.
>>
>> 1) When I use a preexisting table i get a "Object already exists in
>> database" error but when i let fluentnhibernate create a table it
>> works fine'ish except above problem. Am I doing something wrong?
>> 2) Do you create your tables first or let NHiberante do it for you? I
>> ask this because of the question just above.
>> 3) am i just doing something totally wrong? lol.
>>
>> Thanks for any help that can be provided.
>>
>>
>>
>
> >
>
--
Buddy Lindsey
http://www.buddylindsey.com
http://www.twitter.com/buddylindsey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---