Wesley Bakker

Interesting things I encounter doing my job...

Sponsors

News

Wesley Bakker
motion10
Rivium Quadrant 151
2909 LC Capelle aan den IJssel
Region of Rotterdam
The Netherlands
Phone: +31 10 2351035

(feel free to chat with me)
 

Add to Technorati Favorites

SharePoint 2010 BCS model deploy errors

Today I again faced an annoying SharePoint BCS deployment bug. I encountered it before in the beta but figured it would be solved in the release version so I forgot about it. Today it bit me in the rear again.

What's the issue?

As soon as you deploy a BCS solution from VS2010 and changed the model to much from the previous version you deployed, you get all sorts of errors. If you look closely to them, you'll notice they are caused by SharePoint trying to compile previous versions. If you however retract your solution and view Central Admin there are no models defined at all! Somehow these previous versions are stored somewhere we can't view or delete them!

The solution

Sometimes the solution can be very simple. Don't trust the UI, don't trust VS2010 but try the Object Model. After I ran the following code I could find a lot of left over models and entities.

 

using(var site = new SPSite("http://siteurl")){
    var parentFarm = site.WebApplication.Farm;
    var businessDataServices = parentFarm.Services.GetValue();

    var context = SPServiceContext.GetContext(site);
    var catalog = businessDataServices.GetAdministrationMetadataCatalog(context);

    Console.WriteLine("Models:");
    var models = catalog.GetModels("*");
    foreach (var model in models) {
        Console.WriteLine("\t{0}", model.DefaultDisplayName);
    }

    Console.WriteLine("\nEntities:");
    var entities = catalog.GetEntities("*", "*", false);
    foreach (var entity in entities) {
        Console.WriteLine("\t{0}", entity.DefaultDisplayName);
    }               
}
            
Console.ReadLine();

After verrifying all models and entities were indeed left overs I adjusted the code a little bit to delete them.

 

using(var site = new SPSite("http://siteurl")){
    var parentFarm = site.WebApplication.Farm;
    var businessDataServices = parentFarm.Services.GetValue();

    var context = SPServiceContext.GetContext(site);
    var catalog = businessDataServices.GetAdministrationMetadataCatalog(context);

    Console.WriteLine("Models:");
    var models = catalog.GetModels("*");
    foreach (var model in models) {
        Console.WriteLine("\t{0}", model.DefaultDisplayName);
        model.Delete();
    }

    Console.WriteLine("\nEntities:");
    var entities = catalog.GetEntities("*", "*", false);
    foreach (var entity in entities) {
        Console.WriteLine("\t{0}", entity.DefaultDisplayName);
        entity.Delete();
    }               
}
            
Console.ReadLine();

After running the code I could deploy my solution again and all worked fine!

Cheers,

Wes

Posted: Oct 20 2010, 04:40 PM by webbes | with 3 comment(s)
Filed under:

Comments

SharePoint 2010 BCS model deploy errors - Wesley Bakker said:

Pingback from  SharePoint 2010 BCS model deploy errors - Wesley Bakker

# October 20, 2010 2:58 PM

Dew Drop – October 21, 2010 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop – October 21, 2010 | Alvin Ashcraft's Morning Dew

# October 21, 2010 10:29 AM

Twitter Trackbacks for SharePoint 2010 BCS model deploy errors - Wesley Bakker [asp.net] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 SharePoint 2010 BCS model deploy errors - Wesley Bakker         [asp.net]        on Topsy.com

# October 22, 2010 2:24 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)