Sample Header Ad - 728x90

How to compare EF core code-first database with existing Azure Sql Server database

0 votes
0 answers
259 views
we have multi-tenants databases and we have special stored procedure to compare the structure of the tenents after each release. Now, we are moving to Azure SQL Server and the stored procedure is not working anymore because we use the INFORMATION_SCHEMA.TABLES, INFORMATION_SCHEMA.COLUMNS, ... like this: SET @SelectTables = 'SELECT TABLE_SCHEMA + ''.''+ TABLE_NAME FROM '+ @SourceDatabase + '.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE=''BASE TABLE'' ' INSERT INTO #SourceTableNames EXECUTE sp_executesql @SelectTables SET @SelectTables = 'SELECT TABLE_SCHEMA + ''.''+ TABLE_NAME FROM '+ @DestinationDatabase +'.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE=''BASE TABLE'' ' INSERT INTO #DestinationTableNames EXECUTE sp_executesql @SelectTables and we got an error: Reference to database and/or server name in 'Database.INFORMATION_SCHEMA.TABLES' is not supported in this version of SQL Server. In an emergency situation we use Visual Studio SQL Compare or RedGate Compare tools but it would be better to compare the structure of the existing database with a newly created database based on EF Core after each release. Would you please guide me about that? I do not like to compare the tenant one by one after each release with the mentioned tools.
Asked by Fatemeh Ramezani (1 rep)
Apr 8, 2020, 11:12 AM