小编Cso*_*rgo的帖子

EFCore选择错误的列名称

我使用VSCode 创建了一个API .Net coreEFCore遵循教程.

我有很多我的MySQL数据库的模型,因为我是"迁移"我EF6asp.net WebAPI.Net core,所以我只是复制粘贴,避免了大量的工作(再次).

当我尝试做一个简单Get的事情时,EFCore连接两列不同的表:

控制器用户

[Route("v1/[controller]")]
public class UserController : Controller
{

    private readonly IntentContext _context;

    public UserController(IntentContext context)
    {
        _context = context;
    }

    [HttpGet]
    public IEnumerable<user> GetAll()
    {
        return _context.user.ToList();
    }
}
Run Code Online (Sandbox Code Playgroud)

'用户'模型

public class user
{
    public user()
    {
        user_image = new HashSet<user_image>();
        user_credit_card = new HashSet<user_credit_card>();
        user_pocket_history = new HashSet<user_pocket_history>();
        user_pocket = new HashSet<user_pocket>();

        //A lot of table instances
    } …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-core .net-core ef-core-2.0

1
推荐指数
1
解决办法
504
查看次数