-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Hi Team,
I am using .Net Framework 4.6.1
Nuget:
- Microsoft.Data.Sqlite: 8.0.8.0
- zetetic-sqlcipher-windows.4.6.1
- NHibernate: 5.3.0.0
- NHibernate.Extensions.Sqlite: 2.0.5
But When I am Initializing SQLite NHibernate I am getting below error
Can you please help me on that?
The requested collection ‘DataTypes’ is not defined.Microsoft.Data.Sqlite
Refer Below code.
private void BuildSessionFactory()
{
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
var cfg = new Configuration();
//var licenseCode = "YourLicenseCodeHere";
var _connection = (IDbConnection)new SqliteConnection($"Data Source=test.db;");
_connection.Open();
using (var command = _connection.CreateCommand())
{
command.CommandText = $"PRAGMA cipher_license = '{liscense}';";
command.ExecuteNonQuery();
}
using (var command = _connection.CreateCommand())
{
//PRAGMA key ='{key}';
command.CommandText = $"PRAGMA key = 'test@2024';";
command.ExecuteNonQuery();
}
using (var command = _connection.CreateCommand())
{
command.CommandText = "PRAGMA cipher_page_size = 4096";
command.ExecuteScalar();
}
using (var command = _connection.CreateCommand())
{
command.CommandText = "PRAGMA kdf_iter = 256000;";
command.ExecuteScalar();
}
using (var command = _connection.CreateCommand())
{
command.CommandText = "PRAGMA cipher_hmac_algorithm = HMAC_SHA512;";
command.ExecuteScalar();
}
using (var command = _connection.CreateCommand())
{
command.CommandText = "PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA512;";
command.ExecuteScalar();
}
_connection.Close();
cfg.DataBaseIntegration(x =>
{
x.ConnectionString = "Data Source=FIGMD.db;";
x.Driver<NHibernate.Extensions.Sqlite.SqliteDriver>();
x.Dialect<NHibernate.Dialect.SQLiteDialect>();
x.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();
});
//NHibernate.Extensions.Sqlite.SqliteDriver sqlitedriver = new NHibernate.Extensions.Sqlite.SqliteDriver();
cfg.AddAssembly(typeof(Student).Assembly);
var factory=cfg.BuildSessionFactory();
Factories.Add(factory);
//NHibernate.Extensions.Sqlite.SqliteDriver sqliteDriver = new NHibernate.Extensions.Sqlite.SqliteDriver();
}
Exception thrown "var factory=cfg.BuildSessionFactory();" here.
Metadata
Metadata
Assignees
Labels
No labels