Generate Script button is disabled in visual studio after schema comparison
Asked Answered
B

4

21

I would like to create a delta script from the database and my database project. The database as source and database project as target. The Update button works fine without any errors and my Error List contains only this warning:

The login for the source does not have the VIEW ANY DEFINITION permission. The comparison will be restricted to database scoped elements if the target is a database.

This permission: https://technet.microsoft.com/en-us/library/ms175808(v=sql.105).aspx

enter image description here

The post Update target button is disabled after schema comparison did not help me.

How can I active the generate Script Button in Visual Studio Enterprise 2017? Do I really need access to the metadata for script generation?

(edit):

Even with this permission it does not work. But I can generate a script when comparing two databases.

Bronchi answered 23/10, 2017 at 11:52 Comment(2)
I ended up here with the same problem. For me it was a small SQL error buried somewhere in a stored procedure in my Database project. Apparantly the 'generate script' button is disabled if you have errors in the Database project, even when they are unrelated to the changes you are trying to script.Jaclyn
This tool holds so much potential but is so difficult to use. I have errors in my project and I'm trying to fix them by applying fixed database project to the database.... not possible! I have to try and guess the correct DB change, change it in the DB and schema compare to the project and hope it fixes it.Vladamir
M
21

Generate Script button is disabled if your target is a Database project. To generate a script, you could compare with your target database directly instead of database project.

Mciver answered 15/1, 2018 at 9:18 Comment(1)
I confirm this is working however by doing this the script is completely different than the script you need when you compare from the project against the database. I don't fully understand why the GENERATE SCRIPT button is enabled only for PROJECT to DATABASE and not DATABASE to PROJECTCocainize
S
8

Try to build the project, you could have something that doesn't compile

Suffragist answered 23/3, 2020 at 14:44 Comment(0)
A
4

Make sure you rebuild the solution before comparing database schemas. To do this in Visual Studio:

  • Go to Solution Explorer
  • Right click on the root level of the solution
  • Click Rebuild Solution

Rebuild solution

Now try comparing database schemas. You should be able to see generate script option is now enabled.

Amido answered 10/10, 2018 at 3:17 Comment(1)
No. I just tried with Visual Studio 2015 Update 3. I would suggest you to try before giving a solution.Cocainize
S
1

If you don't get errors or warnings make sure in the Sql project properties "Project Settings" that the Target platform match with the SQL Server version that you are comparing with.

When you change it to the correspondence version you will see that the update and generate script buttons will be enabled,

Sst answered 5/7, 2018 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.