当前位置:网站首页>NetCore 5.0连接MySql
NetCore 5.0连接MySql
2022-08-09 14:53:00 【iZaix】
嘿!有坑!
最近需要为调度算法写一个WebApi接口,咦!这个有底货呀,改一改就可以了,抽出点时间可以把它分层,这样以后多个类似项目都可以来用,省事呀…
然而,在新建项目的时候,下拉框里那是多了好几位兄弟啊…(想想我的代码还在2.0时代),好吧(~ _ ~),升级!
建好项目,把代码复制过来,红杠杠?点掉,生成…噹!大红叉!!!找到错误列表,Pomelo.EntityFrameworkCore.MySql 3.2.4与Microsoft.EntityFrameworkCore 5.0.4的版本不兼容,Pomelo需要(>= 3.1.8 && < 5.0.0)的依赖,但是仔细一看Microsoft.EntityFrameworkCore.Relational 5.0.4已解决,这是什么情况…
在Nuget里找一找,Pomelo的最高版本就是3.2.4了,微软的官方文档推荐的第三方包怎么会出现这么大的兼容问题…
找找出处
既然出了版本问题,那这两个东西总要换掉一个,NetCore 5.0那是不想换到低版本了,那么就来看看Pomelo有没有替代方案了,所谓 “冤有头,债有主”,GitHub上看看Pomelo.EntityFrameworkCore.MySql的更新情况,看看大佬怎么说的。
原来已经有5.0.x的支持了,但是测试版。修改**.csproj**文件的引用,噹!报错了…
仔细看看,新版本的变化好大,用法不一样了
改之…
optionsBuilder.UseMySql(_option.ConnectionString,new MySqlServerVersion(new Version(8,0,22)));
总结
在遇到问题的时候,首先是不要慌,明确目标,我这里是需要使用EF Core连接MySql数据库,看了微软推荐的Pomelo,本着兼容性问题,一直在Pomelo方向找办法,如果是尝试其他组件,涉及到不熟悉的方面可能会有更多的弯路需要走,这次也是幸运的,正好能解决,有时候官方推荐的也是个坑(微软常干这事,放弃维护)。
边栏推荐
- What is a template engine?What are the common template engines?Introduction to common commands of thymeleaf.
- 浅谈ArraryList的浅克隆和深克隆
- 几何光学简介
- .Net Core后台任务启停(BackgroundService)
- 欢迎使用CSDN-markdown编辑器
- 多线程学习
- 常见的四种电阻之间有什么不同?
- 为什么要学编译原理
- What are the implications of programmatic trading rules for the entire trading system?
- What is an index in MySql?What kinds of indexes are commonly used?When does an index fail?
猜你喜欢
随机推荐
Analysis: Which method is used to build a stock quantitative trading database?
My MySQL database was attacked and deleted for ransom, forcing me to use all my might to recover data
名词概念总结(不定期更新~~)
What is an index in MySql?What kinds of indexes are commonly used?When does an index fail?
What is the difference between the four common resistors?
异常学习笔记
启动报错:Caused by: org.apache.ibatis.binding.BindingException汇总解决
How can I know if quantitative programmatic trading is effective?
【超级账本开发者系列】专访——肖慧 : 不忘初心,方得始终
How to achieve long-term benefits through the Tongdaxin quantitative trading interface?
方法学习笔记
分析:通过哪种方法来建立股票量化交易数据库?
数据库多表链接查询的方式
思维导图FreeMind安装问题及简单使用
百度地图——鹰眼轨迹服务
对于程序化交易,重在预测还是重在对策呢?
OpenSSF's open source software risk assessment tool: Scorecards
Technology Sharing | How to Handle Header Cookies in Interface Automation Testing
用户如何正确去认识程序化交易?
二叉排序树的左旋与右旋