【问题标题】:EntityFramework does not add dbname with table nameEntityFramework 不添加带有表名的 dbname
【发布时间】:2017-02-16 01:36:02
【问题描述】:

我的实体框架发送插入查询如下

insert into students (
`studentCode`, 
`surname`)
VALUES ('djs', 'andy');

MySql 数据库需要查询为

insert into ge.students (
`studentCode`, 
`surname`)
VALUES ('djs', 'andy');

ge 是数据库名

所以它给了我错误 错误代码:1046。未选择数据库 通过在侧边栏中的 SCHEMAS 列表中双击其名称来选择要使用的默认数据库。

【问题讨论】:

    标签: mysql entity-framework


    【解决方案1】:

    在您的实体类上,查看以下表格注释/属性是否有帮助:

    [Table("students", Schema = "ge")]
    public class Student
    {
        public Student()
        { 
        }
        public int studentCode { get; set; }     
        public string surname { get; set; }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-09-23
      • 2017-02-16
      • 1970-01-01
      • 2022-01-07
      • 1970-01-01
      • 1970-01-01
      • 2013-09-12
      • 2014-09-30
      • 1970-01-01
      相关资源
      最近更新 更多