This project is read-only.
Database Schema Provider gets a database schema in unified format independent on the type of database.
It uses ADO.NET data provider for Entity Framework e.g. http://msdn.microsoft.com/en-us/data/dd363565.aspx.
The principle is following:
I build Entity Framework database schema model dynamically. The conceptual schema of this model is defined by Microsoft and I get it here
res://System.Data.Entity/System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl
I get the Store and the Mapping schema from a ADO.NET data provider manifest
manifest.GetInformation(DbProviderManifest.StoreSchemaDefinition);.

Comment:
I don’t use DbConnection.GetSchema method because the result is depend on the type of database and I was looking for a solution independent on a physical database.

Example:
      string connStr, dataProvider = null;
      // Sample How to read DB schema
      // !!!!!!!!!! Modify connection string for Microsoft SQL Database Nortwind
      dataProvider = "System.Data.SqlClient";
      connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=l:\test\northwnd.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";

      var dbp = new ma.DbSchemaProvider.DbSchemaProvider(dataProvider, connStr);
      var tabDef = dbp.GetTable("Products");
      var colDef = dbp.GetColumns("Products");
      var keyDef = dbp.GetPrimaryKeys("Products");


      // !!!!!!!!!! Modify connection string for Oracle DB
      dataProvider = "Devart.Data.Oracle";
      connStr = @"User Id=HR; Password=hr; Data Source=127.0.0.1:1521/XE";
      dbp = new ma.DbSchemaProvider.DbSchemaProvider(dataProvider, connStr);
      tabDef = dbp.GetTable("JOBS");
      colDef = dbp.GetColumns("JOBS");
      keyDef = dbp.GetPrimaryKeys("JOBS");

Last edited Dec 13, 2010 at 9:42 AM by MirekM, version 3