This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to create an artificial property of a known type for an artificial entity.
The artificial type has a non-key ​Guid field that maps to the ID field of the known type (one-sided relationship). The known type is essentially a reference table. If I were to explicitly write a class for the artificial type, it would look something like:
public
class
ArtificialType
{
public
Guid ID {
get
;
set
;}
public
string
Name {
get
;
set
;}
...etc...
public
Guid TableCodeID {
get
;
set
;}
public
TableCode TableCode {
get
;
set
;}
}
Currently I have:
// Add artificial TableCodeID property (this line is working fine as expected)
userTableConfiguration.HasArtificialPrimitiveProperty(
"TableCodeID"
,
typeof
(Guid)).HasFieldName(
"TableCodeID"
).ToColumn(
"TableCodeID"
);
// Add artificial TableCode<TableCode> object property (auto-generates 'ID2' field and causes exceptions during collection retrieval)
userTableConfiguration.HasArtificialPrimitiveProperty<AttributeTableCode>(
"TableCode"
).AsTransient(
true
);
// Add the association (Prevents the application from compiling unless I remove the 'ToColumn()' call, in which case it adds the 'ID2' field
userTableConfiguration.HasArtificialAssociation(
"TableCode"
,
typeof
(AttributeTableCode)).ToColumn(
"TableCodeID"
);
I never really expected this to work because there's no mention of which field the TableCodeID is supposed to map to unless it assumes the primary key of the related table. And I'm not sure how to use the Artificial API's HasConstraint extension method.
I've also noticed that even trying to add the artificial property with type TableCode causes exceptions to be thrown as it seems to auto-generate an 'ID2' field.
Any help is greatly appreciated. Let me know if you need anything clarified as to what I am trying to achieve.
-Cory