Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Fluent NHibernate to work with SQLite
    primarykey
    data
    text
    <p>I'm sure there is something simple I've not done but I'm trying to get Fluent NHibernate to work with Sqlite on my machine.</p> <p>I used NuGet to download fluent nhibernate and added the following entity and mapping:</p> <pre><code>public class Customer { public virtual string CustomerCode { get; set; } public virtual string Name { get; set; } } public class CustomerMap : ClassMap&lt;Customer&gt; { public CustomerMap () { Id(x =&gt; x.CustomerCode); Map(x =&gt; x.Name); Table("tblCustomer"); } } </code></pre> <p>Then following the getting started with fluent guide I added the following code to a Windows Command project:</p> <pre><code>class Program { static void Main(string[] args) { var sessionFactory = CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { var customer = new Customer { CustomerCode = "123", Name = "Bob" }; session.SaveOrUpdate(customer); transaction.Commit(); } } } private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database( SQLiteConfiguration.Standard .UsingFile("firstProject.db") ) .Mappings(m =&gt; m.FluentMappings.AddFromAssemblyOf&lt;Program&gt;()) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); } private static void BuildSchema(Configuration config) { // delete the existing db on each run if (File.Exists("firstProject.db")) File.Delete("firstProject.db"); // this NHibernate tool takes a configuration (with mapping info in) // and exports a database schema from it new SchemaExport(config) .Create(false, true); } } </code></pre> <p>Finally I added the Sqlite dll using NuGet.. however I'm getting the following error when trying to run the program:</p> <p>Top Exception:</p> <pre><code>An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. </code></pre> <p>Next Exception:</p> <pre><code>Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. </code></pre> <p>Inner most exception:</p> <pre><code>Unable to find the requested .Net Framework Data Provider. It may not be installed. </code></pre> <p>This is when it's trying to create the session factory.</p> <p>Can anyone help with this? I'm running a 32 bit machine?</p> <p>Thanks</p> <p>Dave</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload