跨数据库的数据库元数据读取工具:Database Schema Reader
jopen
9年前
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 }