简体   繁体   English

如何通过在实体框架中添加表来创建DbSet函数

[英]How to create DbSet function from adding a table in Entity framework

I am maintaining the system from previous employees and I can't seem to replicate the creation this model public virtual DbSet<Account> Accounts { get; set; } 我正在维护以前雇员的系统,似乎无法复制此模型的创建。 public virtual DbSet<Account> Accounts { get; set; } public virtual DbSet<Account> Accounts { get; set; } public virtual DbSet<Account> Accounts { get; set; } inside context.cs public virtual DbSet<Account> Accounts { get; set; }在context.cs内部

I have my entity, Bank.edmx then I will add a table. 我有我的实体Bank.edmx,然后将添加一个表。 Account . 帐户

They have this line of code generated from the context.cs but it doesn't appear on my solution when I add the table. 他们具有从context.cs生成的这一行代码,但是当我添加表时它没有出现在我的解决方案中。 在此处输入图片说明

I tried CodeFirst, but its not what they used, it's EF designer from database. 我尝试了CodeFirst,但不是他们使用的东西,而是数据库中的EF设计器。 Anything I am missing when adding the tables for the DbSet to appear? 添加表以显示DbSet时我缺少什么?

after trying and trying, I found it. 经过反复尝试,我找到了它。 You have to tick Pluralize or singularize generated object names for it to have a DbSet 您必须勾选Pluralize or singularize generated object names才能使其具有DbSet

在此处输入图片说明

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

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