简体   繁体   中英

Entity Framework convention for 1to1 relationship

I've looked through various sources and in most of them I see the convention of Entity Framework for 1to1 relationship as eg.

public virtual Product Product {get;set;}

However I found also:

public virtual Product Products {get;set;}

Would there be some specific reason to use the latter convention? I know in one to many it goes Products as below, but I'm particularily interested about 1to1 convention.

public virtual ICollection<Product>Products{get;set;}

That was a Typo in those examples you saw.

Plural names typically indicate a collection, even if there is only 1 item in the collection.

Keep it non-S.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM