问题在于 Access(或 JET Red)没有用于处理其数据模型的单一规范 API,而是您主要通过 OLE-DB 驱动程序或 ODBC 驱动程序。我认为(但无法确认)Office Access GUI 程序可能有自己的内部 API 绕过 OLE-DB 或 ODBC 抽象,不幸的是,GUI 程序在表格等内容中没有使用特定的技术术语设计器(例如,Number > Integer 没有说明它是 16、32 还是 64 位整数,Number > Replication ID 根本不是数字,而是 Win32 GUID)。
截至 2019 年,与用于 JET Red 的较低级别 ODBC API 相比,Microsoft 似乎降低了 OLE-DB 的优先级,但这没关系,因为 ODBC 仍然为我们提供了确定数据库表的设计。
无论如何 - 好消息是您不一定需要一个工具来比较 Access(JET Red)数据库和 SQL Server 数据库,因为您自己很容易获得 ODBC 表规范。
类似这样的:
Dictionary<String,DataTable> jetTables = new Dictionary<String,DataTable>();
using( OleDbConnection jetConnection = new OleDbConnection( "your-access-connection-string") )
{
await jetConnection.OpenAsync().ConfigureAwait(false);
DataTable schemaTable = connection.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables,
new object[] { null, null, null, "TABLE" }
);
foreach( DataRow row in schemaTable.Rows.Cast<DataRow>() )
{
String tableName = (String)row.ItemArray[2];
DataTable tableSchema = connection.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables,
new object[] { null, null, tableName, "TABLE" }
);
jetTables.Add( tableName, tableSchema );
}
}
Dictionary<String,DataTable> sqlTables = new Dictionary<String,DataTable>();
using( SqlConnection sqlConnection = new SqlConnection( "your-sql-server-connection-string" ) )
{
await sqlConnection.OpenAsync().ConfigureAwait(false);
DataTable allTables = new DataTable();
using( SqlCommand cmd1 = sqlConnection.CreateCommand() )
{
cmd1.CommandText = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
using( SqlDataReader rdr1 = await cmd1.ExecuteReaderAsync.ConfigureAwait(false) )
{
allTables.Load( rdr1 );
}
}
foreach( DataRow row in allTables.Rows.Cast<DataRow>() )
{
String tableName = (String)row.ItemArray[0];
using( SqlCommand cmd2 = sqlConnection.CreateCommand() )
{
cmd2.CommandText = "SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @tableName";
cmd2.Parameters.Add( "@tableName", SqlDbType.NVarChar ).Value = tableName;
using( SqlDataReader rdr2 = await cmd2.ExecuteReaderAsync.ConfigureAwait(false) )
{
DataTable dt = new DataTable();
dt.Load( rdr2 );
sqlTables.Add( tableName, dt );
}
}
}
}
然后按照您的意愿将jetTables 与sqlTables 进行比较。