Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I'm trying to mock metadata in my unit tests. I want to set the PrimaryNameAttribute property on EntityMetadata class but it's read only. What is necessary for this to not be null?
Thank you for sharing your question, can you please check the documentation below:
This shows an example of how to create a custom entity and set the PrimaryAttribute for it.
Hope this helps!
The PrimaryNameAttribute is set as part of the initial Create request to create an entity, and cannot then be changed, hence why the property is read-only.
The only way to get a fully-populated EntityMetadata class is to retrieve it via a call to the CRM API
To answer my own question, it's possible to do with XrmFakeEasy's EntityMetadata extension method - SetSealedPropertyValue, which does this behind the scenes:
entityMetadata.GetType().GetProperty("Attributes").SetValue(entityMetadata, attributes, null);
It's possible to do with XrmFakeEasy's SetSealedPropertyValue, or entityMetadata.GetType().GetProperty("Attributes").SetValue(entityMetadata, attributes, null);
Business Applications communities