Hi all! I have class-configurer fluent nhibernate for MySQL:
class MySqlInitializer : INHibernateInitializer
{
public Configuration GetConfiguration()
{
var dbServer = "localhost";
var dbUsername = "root";
var dbName = "nhibernate";
var dbPassword = "";
var ormAssembly = "NHibernate_MySQL.Domain";
var config = Fluently.Configure()
.Database(MySQLConfiguration
.Standard
.ConnectionString(cs => cs
.Server(dbServer)
.Database(dbName)
.Username(dbUsername)
.Password(dbPassword)))
.Mappings(
x =>
x.FluentMappings.AddFromAssembly(Assembly.Load(ormAssembly)));
return config.BuildConfiguration();
}
}
All data's correct. So, I also have integration test (Xunit):
[Fact]
public void GenerateMigrationScript()
{
var config = new MySqlInitializer().GetConfiguration();
var factory = (ISessionFactoryImplementor) config.BuildSessionFactory();
using (var session = factory.OpenSession())
{
var updateScripts = config
.GenerateSchemaUpdateScript(factory.Dialect,
new DatabaseMetadata((DbConnection) session.Connection, factory.Dialect));
foreach (var updateScript in updateScripts)
{
Console.WriteLine(updateScript + ";");
}
}
}
My entities:
public interface IHiberEntutyBase
{
Guid Id { get; set; }
}
public class HiberEntity : IHiberEntutyBase
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
}
class HiberEntityMap : ClassMap<HiberEntity>
{
public HiberEntityMap()
{
Id(x => x.Id).GeneratedBy.Guid();
Map(x => x.Name);
}
}
When I runs GenerateMigrationScript() writes "MySql.Data.MySqlClient.MySqlException: Unknown database 'nhibernate'". Help me please.