I am trying to create a new web application in Web service. I am using this code to do this.
SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);
webAppBuilder.Port = port;
webAppBuilder.RootDirectory = new System.IO.DirectoryInfo(@"C:\Inetpub\wwwroot\wss\VirtualDirectories\" + port);
webAppBuilder.CreateNewDatabase = true;
webAppBuilder.DatabaseName = "WSS_Content_00000000000000000000000000000000";
SPWebApplication newWebApplication = webAppBuilder.Create();
newWebApplication.Provision();
Now I wand to add a new content database to the same web application. According to my understanding I can use this to do it.
newWebApplication.ContentDatabases.Add(new SPContentDatabase());
The new operator should create a new content database instance this is not successful. (NullReferenceException). And the IDE suggests me to use new operator even I already use it.
Any idea on this? Any reference on adding multiple content databases?