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.

cSteusloff
  • 2,487
  • 7
  • 30
  • 51
  • 7
    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. – Bastiaan Linders Oct 04 '18 at 09:49
  • 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. – Nick.Mc Nov 27 '19 at 00:26

4 Answers4

19

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.

Shamal Perera
  • 1,611
  • 1
  • 18
  • 21
  • 2
    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 PROJECT – Marc Roussel May 23 '19 at 14:31
7

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

Michele Bortot
  • 195
  • 2
  • 9
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.

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,

mbadeveloper
  • 1,272
  • 9
  • 16