Closed MarkusKeusch closed 1 year ago
Name | Link |
---|---|
Latest commit | 6cfca8e0d1de58927bad3073f36294dc39499218 |
Latest deploy log | https://app.netlify.com/sites/testcontainers-dotnet/deploys/64ee09ce112d470007d1ea31 |
Deploy Preview | https://deploy-preview-984--testcontainers-dotnet.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Unfortunately, the Microsoft SQL Server Docker image does not support the configuration of the database or username through environment variables during the container start. Changing the modifier to
public
will not create or configure the database. This limitation is from the image itself, rather than a constraint from Testcontainers.Nevertheless, the image does allow the execution of customized SQL scripts (with a couple of adjustments). Along with
WithResourceMapping(bytes[], string)
, we can utilize this to configure the database or username. Furthermore, this enhances the capabilities of the module (image) to similar functionalities like PostgreSQL image offers.Another alternative is to use the EF or override the database in the connection string.
This issue relates:
What @MarkusKeusch and me want is just to have the "initialCatalog" of the connection string set to a specific DB. Of course we can set the initalCatalog in our project manually or make our own extension method. We will care ourself about creating the DB.
But it would be nice to have the functionality directly from testcontainers. I understand that WithDatabase
could lead to false assumptions, that the DB will be created for you.
@HofmeisterAn What do you think about adding an overload for GetConnectionString(), where you can specify the DB, like this: GetConnectionString(string database)
or maybe better: GetConnectionString(string initialCatalog)
Or what if we make a builder method WithInitialCatalog(string database)
? I would like this approach the best, because it would be obvious, that this will not create a DB and you can specify it once, when you by default not want to work with the "master" DB.
You are referring to the workaround mentioned above, in which Entity Framework creates the database if it does not already exist, right? As previously mentioned, I believe this can be quite misleading. If developers do not utilize EF to generate the non-existent database, they run into issues. I will close this issue. Let's continue the discussion in https://github.com/testcontainers/testcontainers-dotnet/issues/986 and see if we can find a suitable solution.
What does this PR do?
Expose the
WithDatabase
method ofMsSqlBuilder
Why is it important?
By default the initial catalog of the connectionstring is set to master. In some cases we want to just delete and recreate the whole database which is not possible for the master database.
Related issues
-