Samra
Samra

Reputation: 2015

EntityFramework does not add dbname with table name

My entity framework sends an insert query as follows

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

MySql database needs the query as

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

ge is the dbname

so it gives me error Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar.

Upvotes: 1

Views: 76

Answers (1)

secretwep
secretwep

Reputation: 716

On your entity class, see if the follow table annotation/attribute helps:

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

Upvotes: 1

Related Questions