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

MySQL Retrieve all Tables in All Databases #108

Closed adelemam closed 4 years ago

adelemam commented 4 years ago

I am connecting with mysql database in dotnet core project, with connection string as following server=5.189.164.15;Uid=remoteUser;database=dbName;port=3306;password=password

but it retrieve all tables in all database together ( not like MSSQL).

sample code: using (var connection = new MySqlConnection("server=5.189.164.15;Uid=remoteUser;database=dbName;port=3306;password=password")) { var databaseReader = new DatabaseSchemaReader.DatabaseReader(connection); //Then load the schema (this will take a little time on moderate to large database structures) allTables = databaseReader.AllTables(); }

martinjw commented 4 years ago

The reader is using Information_Schema, so they find all tables in all databases- SqlServer has better scoping. Simply specify the database you want:

var databaseReader = new DatabaseSchemaReader.DatabaseReader(connection);
databaseReader.Owner = "dbName";
allTables = databaseReader.AllTables();
adelemam commented 4 years ago

wow , thanks a lot worked with me !!