protected override void DbCreateDatabase(DbConnection connection, int?commandTimeout, StoreItemCollection storeItemCollection) { ArgumentUtility.CheckNotNull("storeItemCollection", storeItemCollection); var vfpConnection = ConvertToVfpConnection(connection); var script = DdlBuilder.CreateObjectsScript(storeItemCollection, true); script = script.Replace(";" + Environment.NewLine, " "); CreateDbc(vfpConnection); using (var command = vfpConnection.CreateCommand()) { vfpConnection.DoConnected(() => { var commands = script.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (commands.Length <= 0) { return; } for (int index = 0, total = commands.Length; index < total; index++) { command.CommandText = commands[index]; //try //{ command.ExecuteNonQuery(); //} //catch (OleDbException ex) //{ // Trace.WriteLine("VFP EF Provider - DDL Command Failed: " + command.CommandText + Environment.NewLine + ex.ToString()); //} } }); } }
internal static string CreateObjectsScript(StoreItemCollection itemCollection, bool execScript = false) { var builder = new DdlBuilder(execScript); foreach (var container in itemCollection.GetItems <EntityContainer>()) { builder._tableIndexService.LoadTableIndexes(container); foreach (var entitySet in container.BaseEntitySets.OfType <EntitySet>().OrderBy(s => s.Name)) { builder.AppendCreateTable(entitySet); } foreach (var associationSet in container.BaseEntitySets.OfType <AssociationSet>().OrderBy(s => s.Name)) { builder.AppendCreateForeignKeyRelation(associationSet); } } return(builder.GetCommandText()); }
protected override string DbCreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection) { ArgumentUtility.CheckNotNull("storeItemCollection", storeItemCollection); return(DdlBuilder.CreateObjectsScript(storeItemCollection)); }