Sharing the experience search

Search sharing-the-experience.blogspot.com
Showing posts with label BCS. Show all posts
Showing posts with label BCS. Show all posts

Friday, June 22, 2012

Visual Studio 2010 and BDCM: How to build and deploy



During upgrade from SP2007 to SP2010, we have decided convert 2007 BDC files into 2010 BDCM files.


We did it using hybrid BDC upgrade approach


The exported BDC files I have added to SharePoint project in VS 2010
Creating a Business Data Connectivity Model


The article says each SharePoint project can contain only one model.


It's not true.


You can have as many models as you want in the one visual studio 2010 SharePoint project. 
Just create one project item per feature.


For an example, if you want shipped 10 BDCM models, create 10 features in the project.
Place one project item with BDCM model in each feature.


Identical feature property values from all project items are merged together in the feature manifest. However, if two different project items specify the same feature property key with non-matching values, a validation error occurs.



<Property Key="ModelFileName" Value="BdcModel1\BdcModel1.bdcm" />
So, remember - One project item per feature.
 
Note:
As you may know 2010 SharePoint Foundation allows to use BDCM. But there is one caviat with developing BDCM models in VS 2010 for SharePoint Foundation:

BDC deployment relies on feature event receiver to take care of actions like model import/feature activation. Unfortunately the assembly where the feature event receiver lives does not ship with  SharePoint Foundation. And the reason for that is same assembly has other functionality Microsoft decided not to ship in Foundation.

But, you have a solution to make it work:
 Deploy a BDC Model project to SharePoint Foundation 2010 using Visual Studio 2010
  Publish BDC Model project to SharePoint Foundation 2010 with Visual Studio 2010

Monday, January 30, 2012

BDCM: How to import through PowerShell

[What you have]:
You have a bunch of BDCM files.

[What you want]:
You want to import BDCM files via PowerShell Script.

[What you want to know]: 

[What you want to do]:
Run following in your PowerShell window:

sl {your path to BDCM files}


$MetadataStore = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Catalog" -ServiceContext {your url to CA}


$bdcmFiles = @(Get-ChildItem);
foreach ($bdcmFile in $bdcmFiles)
{


Import-SPBusinessDataCatalogModel -Path $bdcmFile.Name -Identity $MetadataStore -Force


}


[What you want to consider]:


BDCM: How to set permissions through the code?

Friday, October 21, 2011

BDCM: How to set permissions through the code?

[What you have]:
You have a BDCM file.


[What you want]:
You want to set permissions on the model and External Content Types (ECT) through the code.


[What you want to know]: 
You need to make sure that you have at least one access control entity with enough permission to avoid an error:
 At least one user/group in the Access Control List must have the SetPermissions right to avoid creating a non-manageable object.

There are 3 options how you can populate permissions through the code.

[What you want to do]:


1. PowerShell:


 $userAccountAdministrator = "{Domain}\{AdminUser}"; 
 $allUsers = "NT AUTHORITY\Authenticated Users";

 $userAdministrator=[Microsoft.SharePoint.BusinessData.Infrastructure.BdcAccessControlList]::TranslateFriendlyStringToEncodedClaim($userAccountAdministrator);
 $allUsers=[Microsoft.SharePoint.BusinessData.Infrastructure.BdcAccessControlList]::TranslateFriendlyStringToEncodedClaim($allUsers);

 $bdcRightsAdministrator= @([Microsoft.BusinessData.Infrastructure.BdcRights]::Execute, [Microsoft.BusinessData.Infrastructure.BdcRights]::Edit,[Microsoft.BusinessData.Infrastructure.BdcRights]::SetPermissions,[Microsoft.BusinessData.Infrastructure.BdcRights]::UseInBusinessDataInLists,[Microsoft.BusinessData.Infrastructure.BdcRights]::SelectableInClients); 
 $bdcRightsAllUsers= [Microsoft.BusinessData.Infrastructure.BdcRights]::Execute; 


 $aceAdministrator = New-Object "Microsoft.SharePoint.BusinessData.Infrastructure.IndividualAccessControlEntry" -arg $userAdministrator,$bdcRightsAdministrator ;
 $aceAllUsers=New-Object "Microsoft.SharePoint.BusinessData.Infrastructure.IndividualAccessControlEntry" -arg $allUsers,$bdcRightsAllUsers ;

$models=@(
"{Your model1}",
"{Your model2}",
"{Your model3}"
);


foreach ($modelName in $models)
{
$Model = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Model" -name $modelName -ServiceContext {web app url}


$lbsAcl=$Model.GetAccessControlList();                                                                                                                                                                                                                           
$lbsAcl.Add($aceAdministrator);                                                                                                                                                                                                                                                        
$Model.SetAccessControlList($lbsAcl);                                                                                                                                                                                                                           


$entities=$Model.AllEntities;


foreach ($entity in $entities)
    {
      Write-Host $entity.DefaultDisplayName 


      $acl= $entity.GetAccessControlList(); 
      $acl.Add($aceAdministrator);
      $acl.Add($aceAllUsers);                                                                                                                                                                                                                                                           
      $entity.SetAccessControlList($acl);                                                                                                                                                                                                                                         
      $entity.CopyAclAcrossChildren();                                                                                                                                                                                                                                               
    }
}




2.  Feature receiver
Code Snippet: Add an Access Control Entry to a MetadataObject Using the Administration Object Model
  You can copy paste the code into your custom feature receiver.

3. Declaratively in a BDC Model:

  <AccessControlList>
    <AccessControlEntry Principal="{domain}\{AdminUser}">
      <Right BdcRight="Edit" />
      <Right BdcRight="Execute" />
      <Right BdcRight="SetPermissions" />
      <Right BdcRight="SelectableInClients" />
    </AccessControlEntry>
  </AccessControlList>


The BDC Model has a element <AccessControlList> in several places:
1. Permissions on the Model: inside <Model> tag
2. Permissions on External Content Type: inside <Entity> tag
3. Permissions on the method of ECT (in UI if the options is selected "Propagate permissions to all methods of this external content type. Doing so will overwrite existing permissions"): inside <Method> and <MethodInstance>


"SharePoint 2007 to 2010 Upgrade" online project (part 7) : In-place upgrade BDC failed: the bdc service application is not accessible There are no addresses available for this application

[What you have]:
 An Upgraded 2007 farm by means in-place upgrade model ("SharePoint 2007 to 2010 Upgrade" online project (part 3): "Theory"). After you have upgraded the farm, you have
[name of your 2007 SharedServices] - Business Data Connectivity Service where all converted BDC files reside.  On click on that service you are getting the error: 
the bdc service application is not accessible. There are no addresses available for this application

[What you want]:
Fix the error and use the the converted BDC files.

[What you want to know]: 

You may first try to google the error itself. My google findings couldn't  fix the errors. And I ended up removing the broken BDC service. But before removing I exported all converted BDCM files. This post is all about How to export BDCM out of the broken BDCS.
(Btw, still confused with BDC and similar abbreviation? - welcome to read post on SharePoint 2010: BCS and BDC)

[What you want to do]:
Firstly, try to export BDCM using SPD 2010. My attempt has failed. And I happily returned to PowerShell to get my BDCM files out of the Business Connectivity Service 
(Want a quick intro into PowerShell and SharePoint - PowerShell and SharePoint: What, Why and How)


Here is the code to export BDC models:


$models=@(
#array of your model names
);
foreach ($modelName in $models)
{
$path =  "G:\temp\LOCAL\BDCM\{0}.bdcm" -f $modelName;
$Model = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Model" -name $modelName -ServiceContext {your web application URL}
if ($Model -ne $null)
{
Export-SPBusinessDataCatalogModel -Identity $Model -Path $path -force
Write-Host "The model $modelName has been exported";
}
}

Tuesday, October 18, 2011

"SharePoint 2007 to 2010 Upgrade" online project (part 6) : Database attach upgrade. BDC to BCS conversion

[What you have]:
 A new 2010 SharePoint farm. Your upgrade strategy is "database attach".

[What you want]:
You want to install your old BDC files on the farm. And probably, you already know that
BDC ADF files should be converted first in order to work on the new 2010 farm. So, probably you are looking for the easiest way to convert them.

[What you want to know]: 

 In case of "in-place upgrade" Business Data Catalog adf files will be converted automatically. How Business Connectivity Services upgrade works (in-place upgrade). Make a note that a backward-compatible Application Registry Service doesn't have UI interface to manage it.


In case of "database attach" upgrade strategy, you may have read that you can attach SSP database to migrate its content. Truth is: When you attach an SSP database, only your user profile store is upgraded. Search settings, Excel Service settings, Business Data Catalog (BDC) application definitions, and other settings must be recreated from scratch. Upgrading by using database attach (BDC)


You may have even discovered a lengthy MDSN article (How to: Manually Upgrade Business Data Catalog Application Definitions to Business Data Connectivity Models)that follow you through the whole experience with manually editing ADF file to convert it into a BDC Model.  (BTW, still confused with BDC and BCS? - SharePoint 2010: BCS and BDC (Naming convention))


[What you want to do]:
My suggestion to you -
" hybrid BDC upgrade approach".  It's quite simple and probably you have already figured out). 
The idea is to:
1. run "in-place upgrade" on some test 2007 farm with BDC files already installed there;
2. Export BDC Models from the upgraded farm.
3. Import them into a new fresh 2010 farm.



 I see the most common scenario for  "BDC Conversion into Models"  as:
1. "Hybrid BDC upgrade approach"
2. Exporting the upgraded BDC models through SharePoint designer (SPD) 2010.
3. Creating a "Business Data Connectivity Model" project 
4. Deploying a declarative BDC model with  a feature in the new SharePoint 2010 farm.



Regarding details, refer to the material below.

[What you want to consider]:

My fresh experience with BDC upgrade is telling me that you can easily bump into some new errors that you haven't seen before since you have just started using SharePoint 2010.
My recommendation is to follow me. I am planing to get deeper with the BDC conversion and I will share my experience with you.


And some quick notes:


When to Use SharePoint Designer vs. Visual Studio When Building Solutions Using BCS


BDC MetaMan works with .Net connectivity , it won't help with declarative Business Data Catalogs.


The new project template "Business Data Connectivity Model" in Visual Studio 2010  will help you to package and deliver converted BDC. BUT, BDC Model designer in Visual Studio doesn't work with declarative BDC models, only .Net LobSystem,



You can import a model into the Project that was created by using other tools such as SharePoint Designer. You might choose to import an existing model to your project in the following situations:


To customize a model that is already deployed to a SharePoint server farm.


To package and deploy an existing model to multiple SharePoint server farms.


In this scenario this article is a great helpDeploying A Declarative BDC Model with a feature.



Wednesday, June 22, 2011

SharePoint 2010: BCS and BDC

Trying to figure out what's the difference between 2007 BDC and 2010 BCS?
Here is the post for you -enjoy)

[What you have]:

You understand the SharePoint 2007 BDC concept. You are planning to move on SharePoint 2010.


[What you want]:

Understand the difference between 2007 BDC and 2010 BCS concepts.


[What you want to know]:

 BCS - Bussiness Connectivity Services ~ similar to ECM - Enterprise Content Management in 2007.
 BCS in 2010 is NOT an analog of BDC in 2007. It's a smarter replacement for Shared Services in 2007.

BDC  - Business Data Connectivity - in 2010 is a service application which is one of the services under an umbrella of BCS

BDC service holds the BDC models. The BDC model (roughly an analog of adf file) holds the external data configuration:
- connection details;
- authentication details;
- business data entity with one or more external content types (ECT).

External content type - similar to a regular SharePoint content type. The BDC model gets translated into a set of the  ECT. The external content type includes one or more identifiers and stereotyped operations (CRUD)


New opportunities  working with BDC in 2010:

CRUD

BDC 2010 handles CRUD operations. Now on you are able to write  data back to the source of BDC. In previous version of SharePoint 2007 - it was impossible.

External list

Unlike SharePoint lists and content types, each external list is mapped to a single ECT.
The external list doesn't have event receivers and workflow association, item-level security is not supported.

.Net connectivity assemblies 

In 2010 you have 3 types of connection for a BDC model: SQL, WCF, Microsoft .Net type.
.Net connectivity assemblies allows you to:
- aggregate data from multiple services and expose a single date model to SharePoint;
- access data that is not available  through a SQL db connection\ a WCF Web service;
 -transform the data before it got consumed by BDC

Filters and Throttling

Throttling -controls the load that BDC operators put on SharePoint.
Filters - constrain the result set by restriction the scope of the query (control load on the external systems)


[What you want to consider]:

 Do you want deeper understanding - read the book Designing Solutions for Microsoft SharePoint 2010: Making the right architecture and implementation decisions (Patterns & Practices) Part II

Do you want save your money:
1. go to the Bibliography for the book above- Chapter 6
2.  read on MSDN - Business Connectivity Services: How-tos and Walkthroughs