I'm using wixsharp to create database and currently don't know how to setup installation to work for both Sql Server and Windows Authentication.
I created custom credentials dialog where I set Database Name, Catalogue Name, Username, password, and assign these values to constants depending if I select Windows or Sql Server authentication.
For Windows authentication I set only Database Name and Catalogue Name, and for Sql Server I set username and password along with Database and Catalogue names.
var user = new User(new Id("User"), $"[{Constants.DATABASE_USER_NAME}]") { Password = $"[{Constants.DATABASE_PASSWORD}]" };
var database = new SqlDatabase($"[{Constants.DATABASE_CATALOGUE_NAME}]", $"[{Constants.DATABASE_SERVER_NAME}]", SqlDbOption.CreateOnInstall);
database.User = user.Id;
var project = new ManagedProject("Storage",
new Dir(defaultInstallDir),
user, database
);
This implementation works only for Sql Server authentication because the User needs to be asigned to database:
database.User = user.Id
In the case for Windows authentication, when I only set Database and Catalogue Name, the code above will not work and I think this is because of assigning User to database.
In the case when I remove the code for assigning User, Windows Authentication will work fine, but Sql Server Authentication will not work correctly. Instead of creating database with correct User I set in credentials dialog, the database will be created with Windows user.
I know that for Sql Server Authentication user needs to be assigned, and for Windows Authentication it doesn't.
Any ideas how to add logic to installation to handle both cases correctly? Thank you