I have a hard time finding the syntax for this in .NET EF world
Scaffold-DbContext "Server=server_dns,sql_port;Database=db-name; User ID=sql-account;Password=LeetPa$$w0rd;" -StartupProject Solution.Api Microsoft.EntityFrameworkCore.SqlServer -Context ApiDbContext -ContextDir "Data\Context" -OutputDir "..\Solution.Api.Data.Entities\CRL" -Namespace "Solution.Api.Data.Entities.CRL" -ContextNamespace "Solution.Api.Data.Context" -NoOnConfiguring -Force
This is what I got so far:
dotnet ef dbcontext scaffold "Server=server_dns,sql_port;Database=db-name; User ID=sql-account;Password=LeetPa$$w0rd;" -StartupProject Solution.Api Microsoft.EntityFrameworkCore.SqlServer --context ApiDbContext --context-dir "Data\Context" --output-dir "..\Solution.Api.Data.Entities\DBStuff" -Namespace "Solution.Api.Data.Entities.CRL" -ContextNamespace "Solution.Api.Data.Context" -NoOnConfiguring -Force
Failed on Unrecognized option '-StartupProject'
Related
Configure automatic domain join, automatic computer naming, and place new computer accounts in the appropriate organizational unit (OU).
Receive a Deploy request from the reference computer and deploy the install image using PXE and network installation.
this is what I have to do after I configured the active directory and create the users and peppered the WPS server in windows server 2016 but I have no idea what is this or how to do it any think for help please.
• You can achieve the three things, i.e., joining the computer to domain, placing it in an OU and renaming the computer system through a single script but the other two tasks as stated by you, i.e., receive a deploy request from the reference computer and deploy the install image using PXE and network installation should be done afterwards. For the other two tasks, you can configure a Windows Deployment Services server and deploy an image to be deployed to the respective networks, while also enabling PXE in it and the DHCP server scope also.
• Please find the below script to join the computer to a particular OU and rename it thereafter. Create a ‘.csv’ file containing the current names of the computers to be joined to the domain and renamed. Then run the below script on each computer individually: -
‘ Enable-PSRemoting -SkipNetworkProfileCheck -Force ’ --> After running this cmd locally on each computer, run the below script from a domain controller as it will connect remotely through powershell to each computer and join it to domain
‘ Import-Module ActiveDirectory
$inputFilePath = <Path of the csv file>
$computers = Get-Content -Path $inputFilePath
$domain = <domainname>
$credentials = Get-credential -username <domain admin username> -password <password>
foreach ($computer in $computers)
{
$ScriptBlock = {Param($computer)
Add-Computer -DomainName $domain -ComputerName $computer -newname <NewComputerName> -OUPath “OU=testOU,DC=domain,DC=Domain,DC=com”-Credential $credentials -Restart -Force
}
$session = New-PSSession -ComputerName $computer
Invoke-Command -Session $session -ScriptBlock $ScriptBlock -ArgumentList $computer
Remove-PSSession -Session $session
} ’
• For deploying an image through WDS after domain joining through PXE, refer the following link: -
https://www.microsoftpressstore.com/articles/article.aspx?p=3089351&seqNum=4
While running Scaffold-DbContext command in Package Manager Console
Scaffold-DbContext "Server=111.111.111.111;Database=GC_db;User
Id=gg;Password=a#1234;Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context
DatabaseContext -f
Throws an exception
Cannot open database "abc_Form" requested by the
login. The login failed. Login failed for user 'GC\abk'.
Solved!
You can't use both at the same time as above comments by "AlwaysLearning" reply
Scaffold-DbContext "Server=111.111.111.111;Database=GC_db;User
Id=gg;Password=a#1234;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context DatabaseContext -f
Is there a modern approach to exclude manifest certificate private keys from a repository deployment using Azure DevOps without losing related functionality?
I am migrating a code repository that contains a WPF Telerik grid from Team Foundation Server to Azure DevOps. I noticed sensitive information such as an X.509 Certificate Private Key in a TemporaryKey.pfx file that seems to handle the Telerik grid manifest download in production.
I attempted to removed the manifests and OneClick signing outright and see related pages are now throwing errors like the following:
Application manifest has either a different computed hash than the one specified or no hash
Within the .csproj
I see 2 potential lines to remove from the .csproj but I do not want to introduce a security risk if this is a critical security component.
<GenerateManifests>true</GenerateManifests>
<SignManifests>false</SignManifests>
Using a key vault would be another alternative, however I imagine this is circumventing a larger security issue.
Edit:
After some trial and error I have included the corresponding pfx as a secure file and added powershell scripts to install the pfx on the local agent and sign the manifest as I would in the regular application (Sign the OneClick manifests). Now I am receiving
Error MSB3482: An error occurred while signing: A certificate chain
could not be built to a trusted root authority.
My YAML looks like the following:
- task: DownloadSecureFile#1
name: TemporaryKey
displayName: 'Download TemporaryKey certificate'
inputs:
secureFile: 'TemporaryKey.pfx'
#Install TemporaryKey certificate for manifest
- task: PowerShell#2
inputs:
targetType: 'inline'
script: |
Write-Host "Start adding the PFX file to the certificate store."
$secName = "TemporaryKey.pfx"
$tempDirectory = $env:AGENT_TEMPDIRECTORY
$pfxFilePath = Join-Path $tempDirectory $secName
Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxFilePath, "$(Password)", [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()
#Sign manifest using TemporaryKey
- task: PowerShell#2
displayName: "Sign TemporaryKey PowerShell script"
inputs:
targetType: 'inline'
script: |
$magicToken = "#PerformScriptSigning"
$encoding = "UTF8"
$scriptFolder = "."
#No files found here
$scripts = Get-ChildItem -Path $scriptFolder -Filter "*.ps1" -Recurse -ErrorAction Stop
foreach ($script in $scripts) {
try {
$content = Get-Content -Path $script.FullName -Encoding $encoding
if ($content.Contains($magicToken)) {
$content = $content | Where-Object {$_ -notmatch $magicToken}
Set-Content -Value $content -Path $script.FullName -Encoding $encoding -Force
# load cert
$codeSigningCert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
Write-Output "Signing script `"$($script.Name)`" with certificate `"$($codeSigningCert.Thumbprint)`""
# sign script
$null = Set-AuthenticodeSignature -Certificate $codeSigningCert -FilePath $script.FullName -TimestampServer "http://timestamp.comodoca.com/rfc3161"
# copy to artifact staging location
$null = Copy-Item -Path $script.FullName -Destination $env:Build_ArtifactStagingDirectory
}
}
catch {
Write-Error $_
}
}
From my understanding this process should create .ps1 files to sign the project, however there are no .ps1 files found in the signing script. The install script can open the file and does successfully install it to the store. I wrote out the TemporaryKey.pfx cert from before storing it to ensure it was opening without error.
I'm not clear how signing works in this case.
The "modern" or recommended approach would be to upload the .pfx file as secure file to Azure DevOps and then download it and sign your app with it during the build or release pipeline.
This article contains an example of a YAML pipeline that uses a secure .pfx to sign an MSIX packaged WPF app.
I am running this command on Nuget and will show web.config for my connection String. This apps is a web and uses Individual User Account, where namespace like AspNet.Identity are used. The error is 'Cannot open database 'eNtsaRegistration" requested by the login. The login failed. Login failed for user'Mandela\Gcobanim".
Scaffold-DBContext "Data Source=(LocalDb)\MSSQLLocalDB; Initial Catalog=eNtsaRegistration;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
<add name="eNtsaRegistration" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-eNtsaRegistration-20200304090520.mdf;Initial Catalog=aspnet-eNtsaRegistration-20200304090520;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Scaffold-DBContext "Data Source=(LocalDb)\MSSQLLocalDB; Initial Catalog=aspnet-eNtsaRegistration-20200304090520;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
I want setup SharePoint 2010 and SQL Server 2008. When I want to create new configuration database with this command:
New-SPConfigurationDatabase -DatabaseName "SPConfigDB" -AdministrationContentDatabaseName "SPAdminContentDB" -DatabaseServer "DESKTOP-54TIM0H\dadkh" -Passphrase (ConvertTo-SecureString "mypass" -AsPlainText -force) -FarmCredentials (Get-Credential)
run it in SharePoint 2010 Management Shell I have error:
New-SPConfigurationDatabase : Cannot connect to database master at SQL server at DESKTOP-54TIM0H\dadkh. The database migh
t not exist, or the current user does not have permission to connect to it.
At line:1 char:28
+ New-SPConfigurationDatabase <<<< -DatabaseName "SPConfigDB" -AdministrationContentDatabaseName "SPAdminContentDB" -Dat
abaseServer "DESKTOP-54TIM0H\dadkh" -Passphrase (ConvertTo-SecureString "mypass" -AsPlainText -force) -FarmCredent
ials (Get-Credential)
+ CategoryInfo : InvalidData: (Microsoft.Share...urationDatabase:SPCmdletNewSPConfigurationDatabase) [New-S
PConfigurationDatabase], SPException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPConfigurationDatabase
I follow this guide but the problem not solved.
I create a database with name "SPConfigDB" but no result.
problem was IIS!
I check status of IIS and it was not active! so I enable it and problem solved!