Contact is CRM default carried by the Entity, the primary key is <FullName>, development needs associated with primary key field are set to hidden, including <Full Name>, <First Name>, <Last Name>, where <Full name> = <First name> + <Last name>. Then we need to assign a primary key by C # plugin.
At first, I wanted to give <FullName> field assignment directly in the plugin, the code is as follows:
entity.FullName = "test";
The results will not work, code compiler is not passed, because FullName is read-only.
So, we will change another way:
entity["fullname"] = "test";
The code compiles, but when executed may be error, because <Last Name> may be required mandatory.
Modify the code as required, to the mandatory assignment also will be able to:
entity["firstname"] = string.Empty; entity["lastname"] = "test"; entity["fullname"] = "test";