I got my issue solved the following way:
- Create a profile page via SharePoint designer
- Save the site where it was created as site template, import the WSP into Visual Studio and move the module with the profile page to my custom SharePoint solution
- Powershell script to enable the BCS profile host
- Powershell script to create a default action for the BCS entity which points to the deployed profile page
Code snippet for the profile host
function SetBcsProfileHostUrl($siteUrl)
{
$catalog = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Catalog" -ServiceContext $siteUrl
$property = $catalog.Properties | Where { $_.Name -eq "Profile_HostURL" }
if ($property) {
$catalog.Properties.Remove("Profile_HostURL")
}
$catalog.Properties.Add("Profile_HostURL", $siteUrl)
}
Code snippet for the default action
function SetBcsEntityDefaultAction($siteUrl, $entityName, $namespace, $actionUrl, $parameters)
{
$entity = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Entity" -Name $entityName -Namespace $namespace -ServiceContext $siteUrl
$action = $entity.Actions | Where { $_.Name -eq "View Profile" }
if ($action) {
$action.Delete()
}
$newAction = $entity.Actions.Create("View Profile", $false, 1, $false, $siteUrl + $actionUrl, "/_layouts/1033/images/viewprof.gif")
$index = 0
foreach ($parameter in $parameters) {
$newAction.ActionParameters.Create($parameter, $false, $index++) | Out-Null
}
$entity.DefaultAction = $newAction;
$entity.Update();
}