I am using Nhibernate(Fluent) with Sqlite and it worked with no problems what I have done:
Create the POCO EntityClasses for each table like this:
public class tbl_Manufactor : BusinessObject<tbl_Manufactor> { public virtual string Name { get; set; } }
The Entity Classes all inherit from BusinessObject which contains the ID Property and simple CRUD functions I have also other 6 Entity Classes
Create the Mappings with FluentHibernate like this:
using Database.Entitites; using FluentNHibernate.Mapping; namespace Database.Mappings { public class tbl_ManufactorMap : ClassMap<tbl_Manufactor> { public tbl_ManufactorMap() { Id(x => x.ID); Map(x => x.Name); } } }Create the Fluent Config like this:
var Config = Fluently.Configure() .Database(SQLiteConfiguration.Standard .ConnectionString(c=>c.FromConnectionStringWithKey("dbconnection")) .ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<tbl_Manufactor>()) .ExposeConfiguration(cfg => _configuration = cfg) sessionFactory = Config.BuildSessionFactory();
Do a SchemaExport to Create the Schema with:
new SchemaExport(_configuration) .Create(false, true);
Then Nhibernate created a fully working SQlite Database with the right tables!
But then I wanted to add 2 entity classes(I have done it in the same way as before) but when I run my test(which created my first database schema) it not add the new classes(tables) to the database!
The craziest thing is, that the test is always deleting any created database and recreate it with SchemaExport every time I run the test.
Could someone help me?