跨數據庫的數據庫元數據讀取工具:Database Schema Reader
Database Schema Reader 是一個簡單的,跨數據庫的數據庫元數據讀取工具,可以基于 .NET 2.0 DbProviderFactories 讀取數據庫元數據。
任意的 ADO provider 都可以被讀取 (SqlServer, SqlServer CE 4, MySQL, SQLite, System.Data.OracleClient, ODP, Devart, PostgreSql, DB2...) 成單個模塊。
簡單代碼示例
//To use it simply specify the connection string and ADO provider (eg System.Data,SqlClient or System.Data.OracleClient)
const string providername = "System.Data.SqlClient";
const string connectionString = @"Data Source=.\SQLEXPRESS;Integrated Security=true;Initial Catalog=Northwind";
//Create the database reader object.
var dbReader = new DatabaseReader(connectionString, providername);
//For Oracle, you should always specify the Owner (Schema).
//dbReader.Owner = "HR";
//Then load the schema (this will take a little time on moderate to large database structures)
var schema = dbReader.ReadAll();
//There are no datatables, and the structure is identical for all providers.
foreach (var table in schema.Tables)
{
//do something with your model
} 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!