martinjw / dbschemareader

Read database metadata (from SqlServer/Oracle/MySql/SQLite/PostgreSql/DB2 etc) into one simple model
Microsoft Public License
293 stars 128 forks source link

# DatabaseSchemaReader

A simple, cross-database facade over .Net 2.0 DbProviderFactories to read database metadata.

Any ADO provider can be read (SqlServer, SqlServer CE 4, MySQL, SQLite, System.Data.OracleClient, ODP, Devart, PostgreSql, DB2...) into a single standard model. For .net Core, we support SqlServer, SqlServer CE 4, SQLite, PostgreSql, MySQL and Oracle.

https://github.com/martinjw/dbschemareader or https://dbschemareader.codeplex.com/

https://dbschemareader.codeplex.com/documentation

Nuget: Install-Package DatabaseSchemaReader Nuget

Appveyor Build Status

Use

//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 }

* .net (netStandard1.5, netStandard 2.0, net 3.1, net6, net7)
```C#
//In .net Core, create the connection with the connection string
using (var connection = new SqlConnection("Data Source=.\SQLEXPRESS;Integrated Security=true;Initial Catalog=Northwind"))
{
    var dbReader = new DatabaseSchemaReader.DatabaseReader(connection);
    //Then load the schema (this will take a little time on moderate to large database structures)
    var schema = dbReader.ReadAll();

    //The structure is identical for all providers (and the full framework).
    foreach (var table in schema.Tables)
    {
      //do something with your model
    }
}

UIs

There are two simple UIs (.net framework 4.8 only for now).

Building the Source