Detecting foreign key in Entity Framework templates
Posted: Sun 30 Nov 2014 21:03
Given the following snippet, where primitiveProperties and navProperties are set as in your default EntityFramework template, how do I determine the value '????', which is whether a primitive property is also a foreign key?
I need to flag the foreign key properties from my custom method, WriteEdmColumnDefinition
<# foreach (EntityProperty edmProperty in primitiveProperties) {
if (!edmProperty.IsComplexType) {
bool isForeignKey = ???? }
WriteEdmColumnDefinition(edmProperty, isForeignKey, true);
}
#>
I had a commented-out piece of code, but it is flagged as invalid by the template processor, so I'm not sure where I got it from:
bool isForeignKey = navProperties.Any(np=>np.GetDependentProperties().Contains(edmProperty));
I need to flag the foreign key properties from my custom method, WriteEdmColumnDefinition
<# foreach (EntityProperty edmProperty in primitiveProperties) {
if (!edmProperty.IsComplexType) {
bool isForeignKey = ???? }
WriteEdmColumnDefinition(edmProperty, isForeignKey, true);
}
#>
I had a commented-out piece of code, but it is flagged as invalid by the template processor, so I'm not sure where I got it from:
bool isForeignKey = navProperties.Any(np=>np.GetDependentProperties().Contains(edmProperty));