• 记录mysql迁移问题


    如果视图使用DbSet,sql server 是支持的,但是mysql必须是用DbQuery,否则视图会报各种类型转换的异常

    bool类型 使用tinyint 类型,连接字符串加上 TreatTinyAsBoolean=false ,否则也是各种类型的转换失败,比如

    Unable to cast object of type 'System.Boolean' to type 'System.SByte'.

    Unable to cast object of type 'System.Byte[]' to type 'System.Boolean'.

    //下面代码是统一把bool类型制定为MySQL的tinyint(1)类型,context上下文中写这段代码,连接字符串需要加上TreatTinyAsBoolean=false

    var list = modelBuilder.Model.GetEntityTypes().Where(x => !x.IsQueryType).SelectMany(x => x.GetProperties()).Where(x => x.ClrType == typeof(bool) || x.ClrType == typeof(bool?)).Select(x => modelBuilder.Entity(x.DeclaringEntityType.ClrType).Property(x.Name)).ToList();
    foreach (var item in list)
    {
      item.HasColumnType("tinyint(1)");
    }
  • 相关阅读:
    数组
    做了个进制转换图
    类的练习
    3.10l练习
    c#学习第二课
    c#第四课习题
    c#学习第三课
    学习PHP&MYSQL之——字符编码篇(一)
    中缀表达式转换成后缀表达式
    模板方法模式(Template Pattern)
  • 原文地址:https://www.cnblogs.com/dazen/p/13153760.html
Copyright © 2020-2023  润新知