EntityFramework.Extended 支持 MySql
2023-02-18 15:32:05 时间
EntityFramework.Extended 默认不支持 MySql,需要配置如下代码:
[DbConfigurationType(typeof(DbContextConfiguration))] //增加配置
public class SchoolDbContext : DbContext, IDbContext
{
public SchoolDbContext()
: base("name=db_connection")
{
Database.SetInitializer<SchoolDbContext>(null);
}
public DbSet<Student> Students { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema(""); //增加配置
modelBuilder.Configurations.Add(new StudentMap());
}
}
public class DbContextConfiguration : DbConfiguration
{
public DbContextConfiguration()
{
//增加配置
EntityFramework.Locator.Current.Register<EntityFramework.Batch.IBatchRunner>(() => new MySqlBatchRunner());
}
}
相关文章
- 程序员必备之终端模拟器,让你的终端世界多一抹“颜色”
- 搭建博客、自己的小窝?快来看看这些开源静态网站生成器
- 有了这些开源动效项目,设计和开发不再相杀只剩相爱
- 优雅地使用 C++ 制作表格:tabulate
- 真·程序员必修书单
- 命令行版的斗地主你玩过没?
- 统计各个分类和标签下的文章数
- 缩写名词解释
- 用这些免费开源的图标库,为你的项目画龙点睛吧!
- 快速搭建 SpringCloud 微服务开发环境的脚手架
- 这可能就是你苦苦寻找免费、高颜值、功能强大的 Markdown 编辑器(共5款)
- MySQL5.5 升级 5.6
- 免费申请 HTTPS 证书,开启全站 HTTPS
- 和微信公众号编辑器战斗的日子
- 在 Grafana Loki 中用 Logging operator 来访问 Kubernetes pod 日志
- IntelliJ IDEA终于支持对Redis 的可视化窗口操作了,真香!
- 如何实现一个 Kubernetes CSI Driver
- springbootdruidmybatismysql多数据源事务管理
- MySql大小写配置
- Redis集群搭建