I am currently running in an issue on Windows 10 x64 machines which have seemingly no DAO drivers on them.
If I try to create the database via the IMigrator I get the following exception:
COMException: Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154 Class not registered
(FYI my connection string: Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin; Data Source={0};Mode=Share Deny None;Jet OLEDB:Database Password={1} and I use the .UseJetOleDb Method to create the context)
After a bit of playing around I found that if just force the creation of the database via
JetDatabaseCreator.CreateInstance(SchemaProviderType.Adox).CreateDatabase(String.Format(CultureInfo.InvariantCulture, StaticDatabaseSettings.cCConnectionString, pDatabasePath, StaticDatabaseSettings.cCDatabasePassword));
Everything works just fine.
Here my question: Is this the intendet way of forcing this? Is this bad? What are alternative solutions?
For completion the code context where the issue occurs:
var migrator = (IMigrator)context.GetInfrastructure().GetService(typeof(IMigrator));
var appliedMigrations = context.Database.GetAppliedMigrations().ToList();
//DO some non ef core sql stuff
if (!pDatabasePath.Exists)
{
// If this line is removed the mentioned exception occurs, if the database does not already exist
JetDatabaseCreator.CreateInstance(SchemaProviderType.Adox).CreateDatabase(String.Format(CultureInfo.InvariantCulture, StaticDatabaseSettings.cCConnectionString, pDatabasePath, StaticDatabaseSettings.cCDatabasePassword));
}
if (appliedMigrations.LastOrDefault() != StaticDatabaseSettings.cTargetMigration)
{
migrator.Migrate(StaticDatabaseSettings.cTargetMigration);
}
I am currently running in an issue on Windows 10 x64 machines which have seemingly no DAO drivers on them.
If I try to create the database via the IMigrator I get the following exception:
(FYI my connection string:
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin; Data Source={0};Mode=Share Deny None;Jet OLEDB:Database Password={1}and I use the.UseJetOleDbMethod to create the context)After a bit of playing around I found that if just force the creation of the database via
JetDatabaseCreator.CreateInstance(SchemaProviderType.Adox).CreateDatabase(String.Format(CultureInfo.InvariantCulture, StaticDatabaseSettings.cCConnectionString, pDatabasePath, StaticDatabaseSettings.cCDatabasePassword));Everything works just fine.
Here my question: Is this the intendet way of forcing this? Is this bad? What are alternative solutions?
For completion the code context where the issue occurs: