发布:2023/12/7 15:20:21作者:大数据 来源:大数据 浏览次数:525
1、nuget安装MySql.Data.Entity
2、web.config
<connectionStrings>
<add name="sxschool_dotnetContext" connectionString="Server=localhost;Database=schooldb;User=schooldb;Password=123123" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
3、在类名上加上限定表名,如果不加,默认搜索schools表
[Table("school")]
public class School{}
4、在数据库上下文连接dbcontext加上标识
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class sxschool_dotnetContext : DbContext{....
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4