Dilshod
Dilshod

Reputation: 3321

Telerik Data Access One To Zero One association

I am trying to make One To Zero One association between two tables in Telerik Data Access, but can't make it work. Here are my tables:

Student

BackPack

StudentId in Backpack references to Id in Student. When I do the mapping for some reason Telerik is making it One to Zero Many. I need One To Zero One.

Upvotes: 1

Views: 213

Answers (1)

Boyan Palagachev
Boyan Palagachev

Reputation: 86

I assume you are using the Telerik Data Access Visual Designer to model your database? If so, in order to create one-to-one association you need to specify that the ID from one table (Students) matches the ID from the other table (BackPacks). This way each student will have exactly one (or zero) backpack. Please refer to this documentation article which demonstrates the approach.

If this is not applicable in your scenario and you have to match the Student ID to the BackPack StudentId to achieve the same effect you could create one-to-many association and then manually create the unique constraint on the database server side. Alternatively you could switch to Fluent Mapping which allows you to create custom indexes in you mapping.

Upvotes: 1

Related Questions