简体   繁体   English

实体框架是否可以使用列表 <T> 而不是ICollection <T> 从数据库生成类时?

[英]Is it possible to have Entity Framework use List<T> instead of ICollection<T> when generating classes from the DB?

Title is pretty self explanatory. 标题很容易说明。 I would like to have my EF autogenerated partial classes to use List intead of ICollection. 我想让我的EF自动生成的部分类使用ICollection的List intead。

Yes, it is. 是的。 I have done so many times. 我已经做了很多次了。 Are you having some problems generating it? 您在生成它时遇到一些问题吗?

Ex: public virtual List<Property> Properties { get; set; } 例如: public virtual List<Property> Properties { get; set; } public virtual List<Property> Properties { get; set; }

否,因为当您点击.ToList()会返回列表EF时,它将与查询一起访问数据库,因此始终最好在末尾计算.ToList

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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