{"id":545,"date":"2010-08-08T19:23:34","date_gmt":"2010-08-08T17:23:34","guid":{"rendered":"http:\/\/www.itidea.nl\/?p=545"},"modified":"2015-09-08T20:31:30","modified_gmt":"2015-09-08T18:31:30","slug":"bcs-model-some-basics","status":"publish","type":"post","link":"https:\/\/www.itidea.nl\/index.php\/bcs-model-some-basics\/","title":{"rendered":"BCS model \u2013 some basics"},"content":{"rendered":"<p>To create a BCS model in Visual Studio, create a new project based on the template \u2018Business Data Connectivity Model\u2019 and give the project a name. In the next screen you can see a BSC model can be deployed only as a <span style=\"text-decoration: underline;\">farm solution<\/span>, not a sandboxed solution, and select the site for debugging.\u00a0<\/p>\n<p>Visual Studio now creates a couple of things for you:\u00a0<\/p>\n<p>1.\u00a0\u00a0\u00a0 Entity1.cs \u2013 describes the schema for the entity; also known as External Content Type in Central Administration, Business Data Connectivity Service page; a class with properties.<br \/>\n2.\u00a0\u00a0\u00a0 EntityService1.cs \u2013 implementation for CRUD methods. These methods, Create, Read, Update, Delete, can be implemented by the following BCS operations:\u00a0\u00a0\u00a0<\/p>\n<ul>\n<li>Finder (e.g. ReadList)<\/li>\n<li>SpecificFinder (e.g. ReadItem)<\/li>\n<li>Creator (e.g. CreateItem)<\/li>\n<li>Deleter (e.g. DeleteItem)<\/li>\n<li>Updater (regular update and synchronize offline content back to the store)<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\">Visual Studio creates ReadList and ReadItem example methods for you.\u00a0<\/p>\n<p>3.\u00a0\u00a0\u00a0 BdcModel1.bdcm \u2013 the model definition (diagram) in design view, the BDC Designer.<br \/>\n4.\u00a0\u00a0\u00a0 BdcModel1.bdcm.diagram \u2013 the xml definition of the design layout of the model diagram.\u00a0<\/p>\n<p>When you open the .bdcm file in Visual Studio a new Explorer window is available: the BDC Explorer (View, Other Windows, BDC Explorer). \u00a0The layout of this explorer can also be seen when you open the .bdcm file e.g. in Notepad. It is just an xml file which described the whole model: LobInstances, Entities, Methods and MethodInstances, everything. Of course Visual Studio is using this xml file to generate the contents of the BDC Explorer.\u00a0<\/p>\n<p>Another new window can be used when viewing the .bdcm file: BDC Method Details. As the name suggests the details of the methods of the selected entity are displayed: the mapping to the method name and parameters with the Direction (In, Out, InOut, Return) and the Type Descriptor (e.g. Entity1 at ReadItem and IEnumerable&lt;Entity1&gt; at ReadList for the return parameters). You can select an entity on the designer window or the BDC Explorer.\u00a0<\/p>\n<p>When you don\u2019t like the default names for e.g. Entity1, I don\u2019t, you can rename the entity. After renaming the entity switch to the design view of the model. Here the entities name still is Entity1. So make sure you keep in mind there\u2019s no automatic update between the entity definition and the entity design (the model), because the entity on the design represents the metadata and it\u2019s our responsibility to provide the mapping between the code and the metadata.\u00a0<\/p>\n<p>The entity on the design has a custom property which points to the entity service. With this connection the code in the service can be adjusted to the changes made in the design surface or BDC Method Details.\u00a0<\/p>\n<p>Keep in mind that the initially generated ReadList and ReadItem methods in the service are not deleted when you delete the methods at the design surface or BDC Method Details. I don\u2019t know why, loosely coupled? The methods you create yourself are updated very well.\u00a0<\/p>\n<p>Just delete the generated methods in the BDC Method Details and update the service file.\u00a0<\/p>\n<p>Let\u2019s create a Specific Finder method ourselves by selecting \u2018Add a method\u2019 in the BDC Method Details pane and select \u2018Create Specific Finder Method\u2019. A method is created with the default name \u2018ReadItem\u2019 with a return parameter with the name \u2018person\u2019 and Type Descriptor \u2018Person\u2019. Remember that the Type Descriptor displayed here is just a name; it doesn\u2019t tell you the type of the return parameter. At the properties window of the Type Descriptor you will find a property \u2018Type Name\u2019, that\u2019s your type. The default type here is System.String, change this to your type. The format will be &lt;namespace&gt;.&lt;class&gt;, &lt;External System Name&gt;\u00a0<\/p>\n<p>When you create the project the model is named BdcModel1. This name seems to appear on different places. Can I rename this without punishment?\u00a0<\/p>\n<p style=\"text-align: left;\">In the BDC Explorer the name BdcModel1 appears three times:<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelNamesDefault.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-548  aligncenter\" title=\"BDCExplorerBdcModelNamesDefault\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelNamesDefault.png\" alt=\"\" width=\"243\" height=\"159\" \/><\/a><\/p>\n<p>I guess the name of the LobSystemInstances can be changed without punishment at this time, because it is an instance name I don\u2019t use it anywhere because I have basic code. So I start a brand new project and I change the LobSystemInstance name from BdcModel1 to BdcLobInstance. Where can I find this change after deployment?\u00a0<\/p>\n<p style=\"text-align: left;\">Central Administration, Business Data Connectivity Service page: no changes at all. I expected a rename to happen on the External System Instance name:<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameNotChanged.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-549  aligncenter\" title=\"BDCExplorerBdcModelExternalSystemInstanceNameNotChanged\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameNotChanged.png\" alt=\"\" width=\"374\" height=\"177\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameNotChanged.png 374w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameNotChanged-300x141.png 300w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/a>\u00a0<\/p>\n<p>And when creating an external list based on the external content type I expected the name of the datasource to change, but no renaming done\u2026\u00a0<\/p>\n<p style=\"text-align: left;\">Well, allright then, let\u2019s rename the model itself in the BDC Explorer from BdcModel1 to BdcModelChanged:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-550  aligncenter\" title=\"BDCExplorerBdcModelRenameModel\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameModel.png\" alt=\"\" width=\"249\" height=\"164\" \/>\u00a0<\/p>\n<p style=\"text-align: left;\">The model is renamed as expected:<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameModelResult.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-551  aligncenter\" title=\"BDCExplorerBdcModelRenameModelResult\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameModelResult.png\" alt=\"\" width=\"458\" height=\"189\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameModelResult.png 458w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameModelResult-300x123.png 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/a>\u00a0<\/p>\n<p style=\"text-align: left;\">And the Lob instance name is also renamed!<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameChanged.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-552  aligncenter\" title=\"BDCExplorerBdcModelExternalSystemInstanceNameChanged\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameChanged.png\" alt=\"\" width=\"424\" height=\"181\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameChanged.png 424w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalSystemInstanceNameChanged-300x128.png 300w\" sizes=\"auto, (max-width: 424px) 100vw, 424px\" \/><\/a>\u00a0<\/p>\n<p style=\"text-align: left;\">And when creating an external list based on the external content type:<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalDataSourceNameChanged.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-553  aligncenter\" title=\"BDCExplorerBdcModelExternalDataSourceNameChanged\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalDataSourceNameChanged.png\" alt=\"\" width=\"578\" height=\"131\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalDataSourceNameChanged.png 578w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelExternalDataSourceNameChanged-300x67.png 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a>\u00a0<\/p>\n<p>So, something is wrong with my system or the model itself has to be renamed in order to rename the LobSystemInstance name in the browser.\u00a0<\/p>\n<p style=\"text-align: left;\">We still have two items with the same name, let\u2019s rename them too:<br \/>\n<a href=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameAllItems.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-554  aligncenter\" title=\"BDCExplorerBdcModelRenameAllItems\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCExplorerBdcModelRenameAllItems.png\" alt=\"\" width=\"235\" height=\"161\" \/><\/a>\u00a0<\/p>\n<p>The BDC Model name is BdcModelMain, the External System Name is BdcModelSub and the External System Instance Name is BdcLobInstance. All renamed!\u00a0<\/p>\n<p style=\"text-align: left;\">A summary in the following picture:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-555  aligncenter\" title=\"BDCSummaryRename\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCSummaryRename.png\" alt=\"\" width=\"650\" height=\"600\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCSummaryRename.png 650w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2010\/08\/BDCSummaryRename-300x276.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create a BCS model in Visual Studio, create a new project based on the template \u2018Business Data Connectivity Model\u2019 and give the project a name. In the next screen you can see a BSC model can be deployed only &#8230; <a class=\"more-link\" href=\"https:\/\/www.itidea.nl\/index.php\/bcs-model-some-basics\/\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[32,42,6],"class_list":["post-545","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2010","tag-bcs","tag-sharepoint-2010","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/comments?post=545"}],"version-history":[{"count":27,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/545\/revisions\/579"}],"wp:attachment":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}