DatabaseSchemaReader是一个简单的,跨数据库的数据库元数据读取工具,可以基于.NET2.0DbProviderFactories读取数据库元数据。
任意的ADOprovider都可以被读取 (SqlServer,SqlServerCE4,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}
评论