DbUp | NET library that helps you to deploy changes | SQL Database library

 by   DbUp C# Version: 5.0.10 License: MIT

kandi X-RAY | DbUp Summary

kandi X-RAY | DbUp Summary

DbUp is a C# library typically used in Database, SQL Database, MariaDB applications. DbUp has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been run already, and runs the change scripts that are needed to get your database up to date.

            kandi-support Support

              DbUp has a medium active ecosystem.
              It has 1896 star(s) with 513 fork(s). There are 85 watchers for this library.
              It had no major release in the last 12 months.
              There are 151 open issues and 231 have been closed. On average issues are closed in 149 days. There are 49 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of DbUp is 5.0.10

            kandi-Quality Quality

              DbUp has 0 bugs and 0 code smells.

            kandi-Security Security

              DbUp has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              DbUp code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              DbUp is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              DbUp releases are available to install and integrate.
              Installation instructions are available. Examples and code snippets are not available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of DbUp
            Get all kandi verified functions for this library.

            DbUp Key Features

            No Key Features are available at this moment for DbUp.

            DbUp Examples and Code Snippets

            No Code Snippets are available at this moment for DbUp.

            Community Discussions


            Insert multiple rows where not exists
            Asked 2021-Aug-13 at 06:09

            Why is not exists for the insert into #productType table resulting in duplicates? Seems like it should work and I see a ton of SO answers using the same solution but it simply doesn't work. The expected result is to have only a single row inserted into the #productType table.

            All of my code is running under a transaction using DbUp, so I can't use the merge statement either. Any ideas on how to modify this?



            Answered 2021-Aug-13 at 06:09

            You can't do this, as the "not exists" is checked against the producttype state that it was at before this statement ran. so you would have to loop and insert 1 at a time. Best approach would just to use the distinct keyword.

            You query will only ever work on tables which contain data.

            Change your query to this:

            Source https://stackoverflow.com/questions/68763936


            How to apply EF Core migrations if you should not use MigrateAsync() for production environments?
            Asked 2021-Jun-08 at 11:38

            I created a new .Net 5 project and want to use EF Core. I autogenerated multiple migration.cs files using

            dotnet ef migrations add MyMigration

            and want to apply them (for development and production). I know about the MigrateAsync method so I read about how to call this method on startup


            but everywhere I read that this method should not be used for production since those migrations won't be executed in a single transaction (no rollback on errors).

            Unfortunately there are not many resources on how to do it regardless of the environment, I found this article


            One option could be a console app calling the migrations


            but I wasn't able to understand the difference for this approach because it's not solving the transactional problem?

            What are best practises to apply migrations during development/production?

            • After autogenerating migrations I'm a big fan of simplicity, does dotnet ef database update the job and I don't need to work with additional tools?

            • Create a console app, generate .sql files from the migrations, install DbUp and use it for the migration part?



            Answered 2021-Jun-01 at 23:42

            What works best heavily depends on how deployment pipeline works - how many environments are there before production, release cycle, what parts of deployment are automated. There are no universal "best practices" - each way of handling migrations has its own set of tradeoff to be concious about. Pick upgrade procedure according to what your needs and expectations are.

            When setting up EF Core migrations for a mid-sized project (around 70 tables), I tried out few potential approaches. My observations from the process and what worked out in the end:

            1. You want to get a migration SQL somewhere between changing your models and deploying to production, if only to look at it in case there are any breaking changes that may cause issues on rollback. We decided on having migrations directly in project with dbcontext, and have a migration script (using dotnet ef migrations script --idempotent) be generated for every build that can potentially be deployed to any environment - in our case, a CI step for each push to trunk or release branch.
            2. Putting migration SQL in version control and treating SQL as a source of truth in regards to database structure gives an ability to manually modify scripts when you want to keep some columns for backup or backwards compatibility purposes. Another option would be to consider your data model as a reference for database schema and treat migration SQL as intermediate step that is not preserved, which makes it easier to automate whole process, but requires you to handle special cases directly in your datamodel.
            3. Using --idempotent flag when generating migration script gives you a script you can reapply to a database schema regardless of what schema version it was at, having it execute only steps that were not yet executed. This means you can reapply same migration script to already migrated database without breaking schema. If you have different versions of your application running in parallel in separate environments (development, staging and production environment), it can save issues with tracking manually what migration scripts version you need to apply and in what order.
            4. When you have migration SQL, you can use native for your database tools in order to apply them to target environment - such as sqlcmd for SQL Server, psql for postgres. This also has a benefit of having separate user with higher privileges (schema modification) handle migrations, while your application works on limited privileges, that often can't touch the schema.
            5. Applying database migrations is part of application deployment, not application startup - if you have deployment automation of some sorts, it's probably the best place to put executing migrations against target database, again - database native client is a good alternative to DbUp, pick whichever you prefer. Separating migrations from application startup also gives you ability to run an application against mismatched, but still compatible database schema - which comes handy when e.g. you're doing rollout deployments.
            6. Most problems with schema upgrades come from breaking schema compatibility between versions - avoiding that requires being concious about backwards/forward compatibility when working on data model and splitting breaking changes into separate versions that keep at least single step of backwards/forwards compatibility - whether you need it depends on your project, it's something you should decide on. We run full integration test suite for previous version against current database schema and for current version against previous database schema to make sure no breaking changes are introduced between two subsequent versions - any deployment that moves multiple versions will roll out migrations one by one, with assumption that migration script or application startup can include data transformation from old to new model.

            To sum up: generating migration SQL and using either native tools or DbUp on version deploy gives you a degree of manual control over migration process, and ease of use can be achieved by automating your deployment process. For development purposes, you may as well add automatic migrations on application startup, preferably applied only if environment is set to Development - as long as every person on a team has its own development database (local SQL, personal on a shared server, filedb if you use SQL) there are no conflicts to worry about.

            Source https://stackoverflow.com/questions/67761614


            Azure Pipeline fails on `dotnet build` with error "command or file was not found"
            Asked 2021-Jun-07 at 01:59

            Recently I had Azure Pipeline builds start failing, without any changes to my build scripts/yaml. The errors are as follows but they're still pretty light on the details.



            Answered 2021-Jun-07 at 01:59

            The issue was in fact due to the FscToolPath evaluating to an empty string.

            Existing error message accurately conveys the issue; it’s not F#-specific. Something in the .props/.targets files evaluates to dotnet $(PathToFsc) some/file.rsp and the variable $(PathToFsc) (or whatever is in your build scripts) is evaluating to an empty string. The final command that’s executed is then dotnet some/file.rsp and the normal dotnet behavior is to look for dotnet- as an executable.

            The second factor was that the location of FSC did change due to an update of Visual Studio on the VM Image.

            Not an answer, but I wonder if it's related to this: stackoverflow.com/questions/67800998/… - it seems things may have moved between VS 16.9 and 16.10.

            Finally why it impacted me was because I was setting the FscCompilerPath manually due to a TypeProvider that did not support the dotnet core pipeline due to a dependency on System.Data.SqlClient.

            Source https://stackoverflow.com/questions/67815717


            Azure search schema migrations
            Asked 2021-Feb-08 at 14:46

            What's the best way to migrate an Azure search schema in a release pipeline?

            In the SQL world, I'd use something like DbUp. Is there anything similar for Azure search? Or is there a different approach when the schema needs to change?



            Answered 2021-Feb-08 at 14:46

            It depends on whether you are pushing content via the SDK or if you are pulling content from a supported content source using one of the pre-built indexers. Using the SDK you can add new properties to your model as explained in this post: Update Azure search document schema

            Note: Changes in your data model may require either an update or a rebuild of the index. For example, adding new properties only requires and update. But, if you change a setting like searchable, filterable or sortable you will need a rebuild. For details, see How to rebuild an index in Azure Cognitive Search


            My preferred solution is to use push indexing for everything. To test if the data model in the index is compatible, I create a sample item and submit to the index. If the model used in the index is incompatible, and error is thrown by the Azure Search SDK. I then delete the index and create it from scratch using my new model.

            Here is a simplified method to test if any item is compatible with a named index:

            Source https://stackoverflow.com/questions/66097334


            dbup does not create schemaversions table automatically
            Asked 2020-Aug-05 at 11:33

            I installed the latest DbUp version 4.4.0 from nuget and followed the steps described in the docs


            I'm using a MySQL database and created a new .NET Core console project.

            • There is no database present yet. I deleted it

            • I installed the dbup and dbup-mysql package

            • I copied the sample code from the docs and modified it a little bit



            Answered 2020-Aug-05 at 11:33

            The table schemaversions was added correctly but the problem is that you drop the database in your initial script. DbUp does not add it again.

            Source https://stackoverflow.com/questions/63220911


            Azure Devops YAML pipeline - how to repeat a task
            Asked 2020-Apr-24 at 01:46

            In my YAML pipeline I have a deployment job:



            Answered 2020-Apr-24 at 01:46

            I can't test UpdateDatabaseWithDbUp@2 but I have sth what explain how you can achieve your goal. First define templeate.yaml

            Source https://stackoverflow.com/questions/61398206


            Using DBup with octopus deploy error, (System.Data.SqlClient is not supported on this platform.)
            Asked 2020-Mar-19 at 17:51

            I'm using .net core 2.1 project with DBUP library, but when I try to run the DBUP inside octopus deploy the migration tool is returning an error System.Data.SqlClient is not supported on this platform.

            I followed all these steps from an Octopus Documentations https://octopus.com/blog/dbup-database-deployments...

            Already did this steps to fix the problem but without success:

            • net core SDK 2.1, 2.2 installations on the target server
            • Restart the server
            • New release with System.Data.SqlClient nuget package associated with the DBUP Project

            Not sure what I can do more to fix this issue



            Answered 2020-Mar-19 at 17:51

            Found the problem, DBUP project needs to be published isolated from other projects.

            My bad was, trying to run/use dbupproject.dll file as a reference from other projects.

            Source https://stackoverflow.com/questions/60723527


            "EnsureDatabase" fails the first time with: "Database not found on server with connection string in settings"
            Asked 2020-Feb-22 at 23:16

            I am trying to use DbUp to set up migration scripts for my Database. Problem is whenever I use:



            Answered 2020-Feb-22 at 23:16

            Problem happens with 4.3.0 release. Downgrade to 4.0.0 and it won't happen anymore (as a temporary fix till a stable one)

            Source https://stackoverflow.com/questions/60247206

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install DbUp

            Sql CE 4.0 SP1 https://www.microsoft.com/en-us/download/details.aspx?id=30709


            To learn more about DbUp check out the documentation.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone DbUp/DbUp

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link