This question is locked. New answers and comments are not allowed.
I have several many to many tables that OpenAccess did not recognize as such because they have a rowguid column that SqlServer added for replication purposes.
I've gone through the models in the Schema explorer and changed the incorrect table's IsJoinTable property to True.
But what now? Can I force a regeneration of the .cs files?
All of the examples I've seen have been for the older version of OpenAccess.
Any help or links would be appreciated.
[A few hours later]
Here's a specific example of three tables that work. I've got Owner, PhoneNumber and OwnerPhoneNumber (OwnerPhoneNumber did not have the rowguild column so OpenAccess recognized it as a Many-Many table).
OwnerPhoneNumber shows up as a Many-Many table in the Model Schema Explorer. When I pull up Owners in the Mapping Details Editor I see in the Relationships that:
Relates to: PhoneNumber (PhoneNumbers -> Owners) [x] Use join table: OwnerPhoneNumber
Relationship Ends Join Table Ends
Owner Table OwnerPhoneNumber Table
OwnerId:int OwnerId:int
PhoneNumber Table
PhoneNumberId:int PhoneNumberId:int
Now for one that doesn't work. I have the Facility table, PhoneNumber and FacilityPhoneNumber
When I look at the relations in the Mapping Details Editor for Facility the only 'Relates To' drop down I have is for FacilityPhoneNumber. (FacilityPhoneNumbers -> Facility)
[Update]
I'm a bit closer, I think. I deleted the relationships between Facility, PhoneNumber and FacilityPhoneNumber. Made sure that FacilityPhoneNumber is set to IsJoinTable and created an association between Facility and PhoneNumber. The new relationship uses the FacilityPhoneNumber join table. My only problem is that I don't see this relationship in the .CS file. Here's what got generated for the Facility table:
private
IList<PhoneNumber> phoneNumbers =
new
List<PhoneNumbers>();
[Collection(InverseProperty =
"Facility"
, IsManaged =
true
)]
[Storage(
"phoneNumber"
)]
How do I get generated code that looks like:
private
IList<PhoneNumber> phoneNumbers =
new
List<PhoneNumber>();
[JoinTableAssociation(TableName =
"OwnerPhoneNumber"
, OwnerColumns =
"OwnerId"
, TargetColumns =
"PhoneNumberId"
)]
[Column(
"OwnerId"
, OpenAccessType = OpenAccessType.Int32, IsPrimaryKey =
true
, SqlType =
"int"
)]
[Column(
"PhoneNumberId"
, OpenAccessType = OpenAccessType.Int32, IsPrimaryKey =
true
, SqlType =
"int"
)]
[Storage(
"phoneNumbers"
)]
-----
Thanks,
Jason