示例#1
0
        private ISuccessOrErrors CheckMaxLength(SqlColumnInfo sqlCol, EfColumnInfo clrCol, string combinedName)
        {
            var status = SuccessOrErrors.Success("All ok");

            if (sqlCol.MaxLength == -1 && clrCol.MaxLength != -1)
            {
                //SQL is at max length, but EF isn't
                status.AddWarning(
                    "MaxLength: The SQL {0} column {1}.{2}, type {3}, is at max length, but EF length is at {4}.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName, clrCol.ClrColumnType, clrCol.MaxLength);
            }
            else if (sqlCol.MaxLength != clrCol.MaxLength)
            {
                status.AddSingleError(
                    "MaxLength: The  SQL {0}  column {1}.{2}, type {3}, length does not match EF. SQL length = {4}, EF length = {5}.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName, clrCol.ClrColumnType,
                    sqlCol.SqlTypeName.EfLengthIdHalfThis() ? sqlCol.MaxLength / 2 : sqlCol.MaxLength,
                    sqlCol.SqlTypeName.EfLengthIdHalfThis() ? clrCol.MaxLength / 2 : clrCol.MaxLength);
            }

            return(status);
        }
示例#2
0
        private ISuccessOrErrors CheckColumn(SqlColumnInfo sqlCol, EfColumnInfo clrCol, string combinedName)
        {
            var status = new SuccessOrErrors();

            if (sqlCol.SqlTypeName != clrCol.SqlTypeName)
            {
                status.AddSingleError(
                    "Column Type: The SQL {0} column {1}.{2} type does not match EF. SQL type = {3}, EF type = {4}.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName, sqlCol.SqlTypeName, clrCol.SqlTypeName);
            }

            if (sqlCol.IsNullable != clrCol.IsNullable)
            {
                status.AddSingleError(
                    "Column Nullable: SQL {0} column {1}.{2} nullablity does not match. SQL is {3}NULL, EF is {4}NULL.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName,
                    sqlCol.IsNullable ? "" : "NOT ",
                    clrCol.IsNullable ? "" : "NOT ");
            }

            if (sqlCol.IsPrimaryKey != clrCol.IsPrimaryKey)
            {
                status.AddSingleError(
                    "Primary Key: The SQL {0}  column {1}.{2} primary key settings don't match. SQL says it is {3}a key, EF says it is {4}a key.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName,
                    sqlCol.IsPrimaryKey ? "" : "NOT ",
                    clrCol.IsPrimaryKey ? "" : "NOT ");
            }
            else if (sqlCol.IsPrimaryKey && sqlCol.PrimaryKeyOrder != clrCol.PrimaryKeyOrder)
            {
                status.AddSingleError(
                    "Primary Key Order: The SQL {0}  column {1}.{2} primary key order does not match. SQL order = {3}, EF order = {4}.",
                    _sqlDbRefString, combinedName, clrCol.SqlColumnName,
                    sqlCol.PrimaryKeyOrder, clrCol.PrimaryKeyOrder);
            }

            return(status.Combine(CheckMaxLength(sqlCol, clrCol, combinedName)));
        }