Because the .FromAppSetting starts looking for the name you specify in
<appSettings>
instead of
<connectionStrings>
On Fri, Oct 9, 2009 at 4:01 AM, mpetro <[email protected]> wrote:
>
> Thank you for your help. By the way, why
> does .FromConnectionStringWithKey work and .FromAppSetting not?
>
>
>
>
> On Oct 7, 11:16 pm, Mikael Henriksson <[email protected]> wrote:
> > private static ISessionFactory CreateSessionFactory()
> > {
> > return Fluently.Configure()
> > .Database(MsSqlConfiguration.MsSql2008
> > .ConnectionString(c => c
> >
> >
> *.FromConnectionStringWithKey(**"MyStore.Properties.Settings.StoreConnectionString"**)*)
> > )
> > .Mappings(m =>
> > m.FluentMappings
> > .AddFromAssemblyOf<Program>())
> > .ExposeConfiguration(BuildSchema)
> > .BuildSessionFactory();
> > }
> >
> > On Thu, Oct 8, 2009 at 1:45 AM, mpetro <[email protected]> wrote:
> >
> > > Hopefully, this is what you want:
> >
> > > private static ISessionFactory CreateSessionFactory()
> > > {
> > > return Fluently.Configure()
> > > .Database(MsSqlConfiguration.MsSql2008
> > > .ConnectionString(c => c
> > > .FromAppSetting("connectionString"))
> > > )
> > > .Mappings(m =>
> > > m.FluentMappings
> > > .AddFromAssemblyOf<Program>())
> > > .ExposeConfiguration(BuildSchema)
> > > .BuildSessionFactory();
> > > }
> >
> > > and this is from the app.config file:
> >
> > > <connectionStrings>
> > > <add name="MyStore.Properties.Settings.StoreConnectionString"
> > > connectionString="Data Source=.
> > > \SQLEXPRESS;AttachDbFilename=|DataDirectory|\Store.mdf;Integrated
> > > Security=True;User Instance=True"
> > > providerName="System.Data.SqlClient" />
> > > </connectionStrings>
> >
> > > Thanks for looking into this, by the way.
> >
> > > On Oct 7, 3:14 am, Mikael Henriksson <[email protected]> wrote:
> > > > That's not your initialization code. Paul was asking you to post your
> > > > Fluently.Configure.... there are numerous ways to use a connection
> > > string.
> > > > Is it an appSetting? connectionString? etc.
> > > > .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c =>
> > > > c.FromConnectionStringWithKey("yourNamedConnectionString")))
> > > > .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c =>
> > > > c.FromAppSetting("YourKey")))
> > > > .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c =>
> >
> > >
> c.Is(ConfigurationManager.ConnectionString["yourNamedConnectionString"].ConnectionString))
> > > > .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c =>
> > > > c.Server("YourServer\Instance").Username("sa").Password("password")))
> >
> > > > So to help you out we need your whole configuration part.
> >
> > > > On Wed, Oct 7, 2009 at 4:47 AM, mpetro <[email protected]> wrote:
> >
> > > > > Straight from the app.config file:
> >
> > > > > connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|
> > > > > DataDirectory|\Store.mdf;Integrated Security=True;User
> Instance=True"
> >
> > > > > -mpetro
> >
> > > > > On Oct 6, 6:03 pm, Paul Batum <[email protected]> wrote:
> > > > > > Okay, can you post your initialization code?
> >
> > > > > > On Wed, Oct 7, 2009 at 10:52 AM, mpetro <[email protected]>
> wrote:
> >
> > > > > > > In fact, I'm working through that example. However, I can't
> get a
> > > > > > > connection to SQL Server Express. The code errors and stops
> > > executing
> > > > > > > in the MsSqlConnectionStringBuilder.Create() method.
> >
> > > > > > > -mpetro
> >
> > > > > > > On Oct 6, 3:52 am, Paul Batum <[email protected]> wrote:
> > > > > > > > Which example are you following exactly? I recommend you
> follow
> > > the
> > > > > > > getting
> > > > > > > > started guide on the wiki if you aren't already:
> > > > > > >http://wiki.fluentnhibernate.org/Getting_started
> >
> > > > > > > > On Mon, Oct 5, 2009 at 5:50 AM, mpetro <[email protected]>
> > > wrote:
> >
> > > > > > > > > Hi there. I'm new to Fluent NHibernate and can't seem to
> get
> > > > > > > > > started. I'm trying the First Example to make sure my
> > > installation
> > > > > > > > > works, but it stops with an error in the
> > > > > > > > > MsSqlConnectionStringBuilder.Create method with the message
> > > shown
> > > > > > > > > above.
> >
> > > > > > > > > I searched and found this:
> >
> > > > >
> http://www.mailinglistarchive.com/[email protected]/.
> > > > > > > ..
> >
> > > > > > > > > but this indicates that the problem was taken care of.
> > > Somehow,
> > > > > I'm
> > > > > > > > > seem to having the same issue.
> >
> > > > > > > > > Is anybody having this same problem, or does someone have a
> > > > > solution
> > > > > > > > > that they wouldn't mind sharing?
> >
> > > > > > > > > I'm using V C# Express with SQLExpress, tried FNH from
> > > pre-built
> > > > > > > > > binaries and also built from source using Ruby.
> >
> > > > > > > > > Warm regards,
> > > > > > > > > mpetro
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---