context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
if (context.MessageName == "Create")
//Code to be executed during Create event of an entity
if (context.MessageName == "Update”)
//Code to be executed during Update event of an entity
MessageName is assigned when we create step by using Plugin registration tool as shown.
Above code shows how to differentiate between the Create and Update events.
Delete event works in a different way. Please refer the following link