How to get a list of all identity columns in a database

Here is some code to get a list of identity columns in database.

select as TableName,  + o.list as IdentityColumnName 
from    sysobjects so
cross apply
           case when exists ( 
        select id from syscolumns
        where object_name(id)
        and name=column_name
        and columnproperty(id,name,'IsIdentity') = 1 
        ) then
        end + ' '
     from information_schema.columns where table_name =
    ) o (list)
where   xtype = 'U'
AND o.list is not null
AND name    NOT IN ('dtproperties')

Check if a database exists on a server

Here is some code to use to check if a database exists.
Just replace the string 'DATABASE NAME’.

SELECT * FROM [master].[sys].[databases] WHERE name='DATABASE NAME'

How to switch Entity Framework database connected to

If you have a connection to a database through entity framework and you need to switch it to another database (with the exact same structure) you just need to set the Connection.ConnectionString (as seen below).
I had an application where we created a copy of the Master database when setting up a new client.  So using Entity Framework I switched from the master database to the client (depending on what the admin was doing).

using (MasterEntities aEntities = new MasterEntities())

//Switch db connected to

aEntities.Database.Connection.ConnectionString = aEntities.Database.Connection.ConnectionString.Replace("OldDatabaseName", "NewDatabaseName"); //Some Query