我创建了一个类,它对 MySql 数据库中的现有表进行建模。下面是课程:
public class class1
{
[Key]
public int id { get; set; }
public int LastName { get; set; }
public int FirstName { get; set; }
}
我还创建了一个此类。
public class Dbo : DbContext
{
public DbSet<class1> Classs { get; set; }
}
我已经创建了我的控制器。现在,当我运行应用程序时,出现此错误:
MySql.Data.MySqlClient.MySqlException was unhandled by user code
Message=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`LastName` int NOT NULL,
`Fi' at line 2
Source=MySql.Data
ErrorCode=-2147467259
Number=1064
MySql 表有这样的结构:
`id` int(11) NOT NULL,
`LastName` int(11) NOT NULL,
`FirstName` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT