I am sure there is something simple that I did not do, but I am trying to get Fluent NHibernate to work with Sqlite on my machine.
I used NuGet to download nhibernate for free and added the following entity and display:
public class Customer { public virtual string CustomerCode { get; set; } public virtual string Name { get; set; } } public class CustomerMap : ClassMap<Customer> { public CustomerMap () { Id(x => x.CustomerCode); Map(x => x.Name); Table("tblCustomer"); } }
Then, after starting the free tutorial, I added the following code to the Windows Command project:
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 => m.FluentMappings.AddFromAssemblyOf<Program>()) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); } private static void BuildSchema(Configuration config) {
Finally, I added the Sqlite dll using NuGet .. however, when I try to start the program, I get the following error:
Top exception:
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
The following exception:
Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
Inner majority of exceptions:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
This is when he tries to create a factory session.
Can anyone help with this? Am I running a 32 bit machine?
thanks
Dave
Crafttyfella
source share