本文介绍了关于实体框架的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对实体框架实体模型有一点疑问。实体框架使用ICollection创建模型的导航属性。但由于索引,我需要List。
我的问题是;我可以将这些属性更改为如下所示的列表吗?
谢谢。
我的尝试:
Hi,
I have a little question about entity framework entity models. The entity framework creates model's navigation properties with ICollection. But I need List's because of indexing.
My question is; Can I change these properties to Lists like below?
Thank you.
What I have tried:
public partial class Student
{
public Student()
{
Courses = new HashSet<Course>();
}
public int ID;
public string Name;
public virtual ICollection<Course> Courses { get; set; }
}
to
to
public partial class Student
{
public Student()
{
Courses = new HashSet<Course>();
}
public int ID;
public string Name;
public virtual IList<Course> Courses { get; set; }
}
推荐答案
这篇关于关于实体框架的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!