Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TargetFile validation on Extract #128

Closed
dzsquared opened this issue Aug 15, 2022 · 5 comments
Closed

TargetFile validation on Extract #128

dzsquared opened this issue Aug 15, 2022 · 5 comments
Assignees
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release good first issue Good for newcomers
Milestone

Comments

@dzsquared
Copy link
Contributor

  • SqlPackage or DacFx Version: SqlPackage 19.1
  • .NET Framework (Windows-only) or .NET Core: .net core
  • Environment (local platform and source/target platforms):

Steps to Reproduce:

  1. Extract a database with the extracttarget property set to anything other than the default (dacpac), set the target file to either a folder path or a *.sql file
  2. Receive an error that the target file isn't a .dacpac The TargetFile argument must refer to a file with a '.dacpac' extension.

(new error related to the addition of /p:ExtractTarget)

@dzsquared dzsquared added the bug Something isn't working label Aug 15, 2022
@zijchen zijchen added the good first issue Good for newcomers label Oct 17, 2022
@namangupta211 namangupta211 self-assigned this Nov 3, 2022
@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 22, 2023

@dzsquared Is this really not fixed yet?

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 22, 2023

@dzsquared @zijchen "good first issue" 😄 - if only this was open source, I would be happy to take it!

@dzsquared dzsquared assigned dzsquared and unassigned namangupta211 Aug 28, 2023
@dzsquared dzsquared added the fixed-pending-release Fix in upcoming release label Aug 28, 2023
@zijchen
Copy link
Member

zijchen commented Oct 19, 2023

Fixed with 162.1.167

@zijchen zijchen closed this as completed Oct 19, 2023
@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 20, 2023

Looking forward to testing this and updating my blog post here https://erikej.github.io/efcore/dotnet/azure/dacfx/2023/08/31/from-database-to-ef-core-webapi-via-cli.html

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 20, 2023

It works great! Allowing the following CLI work flow:

Create the database project - .dacpac package

Run sqlpackage to create .sql scripts for all objects from the Azure SQL Database in a folder:

sqlpackage /a:Extract /p:ExtractTarget=SchemaObjectType /tf:AdventureWorks /scs:"data source=myserver.database.windows.net;initial catalog=AdWorks;user id=sqlfamily;password=sqlf@m1ly;encrypt=True;Connect Timeout=60" 

For details on the sqlpackage extract action syntax, see the documentation here.

Use the sqlproj template to create a new SQL project:

dotnet new sqlproj -n AdventureWorks

Finally, you can build a .dacpac package, which can be used to publish the database schema in your deployment scripts and as the basis for code generation in the following steps.

dotnet build .\AdventureWorks\AdventureWorks.sqlproj

You should see output similar to this, to confirm that the .dacpac package is built:

  Writing model to C:\Temp\PowerTools\AdventureWorks\obj\Debug\Model.xml...
  AdventureWorks -> C:\Temp\PowerTools\AdventureWorks\bin\Debug\AdventureWorks.dll
  AdventureWorks -> C:\Temp\PowerTools\AdventureWorks\bin\Debug\AdventureWorks.dacpac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants