SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is it possible to define an external contentType in code?
As an alternative: Is it possible to deploy an bdc-model using code (i.e. create the xml "on the fly" then deploy that using code)?

share|improve this question
up vote 2 down vote accepted

For sure it is. Visual Studio 2010 has even a project item template for it. Have a look here for something to get you started.

The ECT gets created automatically by your BDC model upon solution deployment.

share|improve this answer
but when that is said, it is MUCH easier to get the foundation for the code by using SharePoint Designer :-) (and that is just about the only thing that tool is useful for) – Anders Rask Jun 4 '12 at 9:45
Thanks for the info, but is is possible to do this "in code"? I.e. not in a Solution/WSP? Or better can I do var bdcm = this.CreateBdcm(); this.InstallToFarm(bdcm);? – Nils Jun 4 '12 at 9:50
what do you mean by "in code" this case, ECMA Javascript? - if your BDC model doesn't exist already on the farm, i don't see it as an easy task. You could create/deploy the model even via SPD (the easy way and no-code solution) and probably with a little effort you could create an instance of the ECT via ECMA script. Otherwise, the best way would be to deploy your model via .WSP – Marius Constantinescu - MVP Jun 4 '12 at 10:00
with "in code" I mean using c# and sharepoint object model. – Nils Jun 4 '12 at 10:49
You could use this to create/export your BDC and then use either the UI, or PowerShell (e.g.…) or…. Haven't tried by code but a similar as the Powershell should do it. – Marius Constantinescu - MVP Jun 4 '12 at 20:30

For completeness:

I found what I was looking for in the MSDN-Article "Code Snippet: Create an External Content Type Using the Administration Object Model".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.