DO can't create schema or database automatically, it's only creates structure of schema.
But!
During domain building there are few points when you can customize domain building.
You can implement your Upgrade handler and on prepare stage execute query what you need
For example, we have some model and handler
[HierarchyRoot]
public SomeEntity: Entity
{
[Field, Key]
public int Id{get; private set;}
[Field]
public string TextField {get;set;}
}
// custom upgrade handler.
// It provides you access to some points of upgrade process
// You can manipulate upgrade using overloads of UpgradeHandler's virtual methods.
public class CustomUpgradeHandler : UpgradeHandler
{
public override bool CanUpgradeFrom(string oldVersion)
{
return true;
}
public override void OnPrepare()
{
using (var connection = new MySql.Data.MySqlClient.MySqlConnection()) {
connection.Open();
using (var command = connection.CreateCommand()) {
command.CommandText = "your query to MySql";
command.ExecuteNonQuery();
}
connection.Close();
}
}
}
than we register types in domain configuration
...
var domainConfiguration = new DomainConfiguration(...);
domainConfiguration.Types.Register(typeof (SomeEntity));
domainConfiguration.Types.Register(typeof (CustomUpgradeHandler));
...
And that's all. DO will execute your manual query before building domain.
answered
Oct 30 '14 at 02:05
Alexey Kulakov
772●2●5