├── .editorconfig ├── .gitattributes ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── build.yml ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── Development.props.sample ├── Directory.Build.props ├── Directory.Packages.props ├── LICENSE ├── NuGet.config ├── Pomelo.EFCore.MySql.sln ├── Pomelo.snk ├── README.md ├── Version.props ├── dotnet-tools.json ├── global.json ├── icon.png ├── rulesets ├── Documentation.ruleset ├── EFCore.ruleset ├── FxCop.ruleset └── StyleCop.ruleset ├── src ├── Directory.Build.props ├── EFCore.MySql.Json.Microsoft │ ├── Design │ │ └── Internal │ │ │ └── MySqlJsonMicrosoftDesignTimeServices.cs │ ├── EFCore.MySql.Json.Microsoft.csproj │ ├── Extensions │ │ ├── Internal │ │ │ ├── MySqlJsonMicrosoftPropertyBuilderExtensions.cs │ │ │ └── MySqlJsonMicrosoftPropertyExtensions.cs │ │ ├── MySqlJsonMicrosoftDbContextOptionsBuilderExtensions.cs │ │ ├── MySqlJsonMicrosoftPropertyBuilderExtensions.cs │ │ ├── MySqlJsonMicrosoftPropertyExtensions.cs │ │ └── MySqlJsonMicrosoftServiceCollectionExtensions.cs │ ├── Infrastructure │ │ └── Internal │ │ │ └── MySqlJsonMicrosoftOptionsExtension.cs │ ├── Query │ │ └── Internal │ │ │ ├── MySqlJsonMicrosoftDomTranslator.cs │ │ │ ├── MySqlJsonMicrosoftMemberTranslatorPlugin.cs │ │ │ ├── MySqlJsonMicrosoftMethodCallTranslatorPlugin.cs │ │ │ └── MySqlJsonMicrosoftPocoTranslator.cs │ ├── Scaffolding │ │ └── Internal │ │ │ └── MySqlJsonMicrosoftCodeGeneratorPlugin.cs │ ├── Storage │ │ ├── Internal │ │ │ ├── MySqlJsonMicrosoftTypeMapping.cs │ │ │ └── MySqlJsonMicrosoftTypeMappingSourcePlugin.cs │ │ ├── ValueComparison │ │ │ └── Internal │ │ │ │ └── MySqlJsonMicrosoftValueComparer.cs │ │ └── ValueConversion │ │ │ └── Internal │ │ │ ├── MySqlJsonMicrosoftJsonDocumentValueConverter.cs │ │ │ ├── MySqlJsonMicrosoftJsonElementValueConverter.cs │ │ │ ├── MySqlJsonMicrosoftPocoValueConverter.cs │ │ │ └── MySqlJsonMicrosoftStringValueConverter.cs │ ├── build │ │ └── netstandard2.0 │ │ │ └── Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.targets │ └── docs │ │ └── README.md ├── EFCore.MySql.Json.Newtonsoft │ ├── Design │ │ └── Internal │ │ │ └── MySqlJsonNewtonsoftDesignTimeServices.cs │ ├── EFCore.MySql.Json.Newtonsoft.csproj │ ├── Extensions │ │ ├── Internal │ │ │ ├── MySqlJsonNewtonsoftPropertyBuilderExtensions.cs │ │ │ └── MySqlJsonNewtonsoftPropertyExtensions.cs │ │ ├── MySqlJsonNewtonsoftDbContextOptionsBuilderExtensions.cs │ │ ├── MySqlJsonNewtonsoftPropertyBuilderExtensions.cs │ │ ├── MySqlJsonNewtonsoftPropertyExtensions.cs │ │ └── MySqlJsonNewtonsoftServiceCollectionExtensions.cs │ ├── Infrastructure │ │ └── Internal │ │ │ └── MySqlJsonNewtonsoftOptionsExtension.cs │ ├── Query │ │ └── Internal │ │ │ ├── MySqlJsonNewtonsoftDomTranslator.cs │ │ │ ├── MySqlJsonNewtonsoftMemberTranslatorPlugin.cs │ │ │ ├── MySqlJsonNewtonsoftMethodCallTranslatorPlugin.cs │ │ │ └── MySqlJsonNewtonsoftPocoTranslator.cs │ ├── Scaffolding │ │ └── Internal │ │ │ └── MySqlJsonNewtonsoftCodeGeneratorPlugin.cs │ ├── Storage │ │ ├── Internal │ │ │ ├── MySqlJsonNewtonsoftTypeMapping.cs │ │ │ └── MySqlJsonNewtonsoftTypeMappingSourcePlugin.cs │ │ ├── ValueComparison │ │ │ └── Internal │ │ │ │ └── MySqlJsonNewtonsoftValueComparer.cs │ │ └── ValueConversion │ │ │ └── Internal │ │ │ ├── MySqlJsonNewtonsoftJTokenValueConverter.cs │ │ │ ├── MySqlJsonNewtonsoftPocoValueConverter.cs │ │ │ └── MySqlJsonNewtonsoftStringValueConverter.cs │ ├── build │ │ └── netstandard2.0 │ │ │ └── Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.targets │ └── docs │ │ └── README.md ├── EFCore.MySql.NTS │ ├── Design │ │ └── Internal │ │ │ └── MySqlNetTopologySuiteDesignTimeServices.cs │ ├── EFCore.MySql.NTS.csproj │ ├── Extensions │ │ ├── MySqlNetTopologySuiteDbContextOptionsBuilderExtensions.cs │ │ ├── MySqlNetTopologySuiteServiceCollectionExtensions.cs │ │ └── MySqlSpatialDbFunctionsExtensions.cs │ ├── Infrastructure │ │ └── Internal │ │ │ └── MySqlNetTopologySuiteOptionsExtension.cs │ ├── Properties │ │ ├── MySqlNTSStrings.Designer.cs │ │ ├── MySqlNTSStrings.Designer.tt │ │ └── MySqlNTSStrings.resx │ ├── Query │ │ ├── ExpressionTranslators │ │ │ └── Internal │ │ │ │ └── MySqlDbFunctionsExtensionsMethodTranslator.cs │ │ └── Internal │ │ │ ├── MySqlGeometryCollectionMemberTranslator.cs │ │ │ ├── MySqlGeometryCollectionMethodTranslator.cs │ │ │ ├── MySqlGeometryMemberTranslator.cs │ │ │ ├── MySqlGeometryMethodTranslator.cs │ │ │ ├── MySqlLineStringMemberTranslator.cs │ │ │ ├── MySqlLineStringMethodTranslator.cs │ │ │ ├── MySqlMultiLineStringMemberTranslator.cs │ │ │ ├── MySqlNetTopologySuiteEvaluatableExpressionFilter.cs │ │ │ ├── MySqlNetTopologySuiteMemberTranslatorPlugin.cs │ │ │ ├── MySqlNetTopologySuiteMethodCallTranslatorPlugin.cs │ │ │ ├── MySqlPointMemberTranslator.cs │ │ │ ├── MySqlPolygonMemberTranslator.cs │ │ │ └── MySqlPolygonMethodTranslator.cs │ ├── Scaffolding │ │ └── Internal │ │ │ └── MySqlNetTopologySuiteCodeGeneratorPlugin.cs │ ├── Storage │ │ ├── Internal │ │ │ ├── MySqlGeometryTypeMapping.cs │ │ │ └── MySqlNetTopologySuiteTypeMappingSourcePlugin.cs │ │ └── ValueConversion │ │ │ └── Internal │ │ │ └── GeometryValueConverter.cs │ ├── build │ │ └── netstandard2.0 │ │ │ └── Pomelo.EntityFrameworkCore.MySql.NetTopologySuite.targets │ └── docs │ │ └── README.md ├── EFCore.MySql │ ├── DataAnnotations │ │ ├── MySqlCharSetAttribute.cs │ │ └── MySqlCollationAttribute.cs │ ├── Design │ │ └── Internal │ │ │ ├── MySqlAnnotationCodeGenerator.cs │ │ │ ├── MySqlCSharpRuntimeAnnotationCodeGenerator.cs │ │ │ └── MySqlDesignTimeServices.cs │ ├── Diagnostics │ │ ├── Internal │ │ │ └── MySqlLoggingDefinitions.cs │ │ └── MySqlEventId.cs │ ├── EFCore.MySql.csproj │ ├── Extensions │ │ ├── DbDataReaderExtensions.cs │ │ ├── DbDataRecordExtensions.cs │ │ ├── IEnumerableExtensions.cs │ │ ├── MySqlCommonJsonChangeTrackingOptionsExtensions.cs │ │ ├── MySqlComplexTypePropertyBuilderExtensions.cs │ │ ├── MySqlDatabaseFacadeExtensions.cs │ │ ├── MySqlDbContextOptionsBuilderExtensions.cs │ │ ├── MySqlDbFunctionsEnums.cs │ │ ├── MySqlDbFunctionsExtensions.cs │ │ ├── MySqlEntityTypeBuilderExtensions.cs │ │ ├── MySqlEntityTypeExtensions.cs │ │ ├── MySqlIndexBuilderExtensions.cs │ │ ├── MySqlIndexExtensions.cs │ │ ├── MySqlJsonDbFunctionsExtensions.cs │ │ ├── MySqlKeyBuilderExtensions.cs │ │ ├── MySqlKeyExtensions.cs │ │ ├── MySqlMigrationBuilderExtensions.cs │ │ ├── MySqlModelBuilderExtensions.cs │ │ ├── MySqlModelExtensions.cs │ │ ├── MySqlPropertyBuilderExtensions.cs │ │ ├── MySqlPropertyExtensions.cs │ │ ├── MySqlServiceCollectionExtensions.cs │ │ └── StringExtensions.cs │ ├── Infrastructure │ │ ├── CharSet.cs │ │ ├── Internal │ │ │ ├── IMySqlOptions.cs │ │ │ ├── MySqlJsonOptionsExtension.cs │ │ │ └── MySqlOptionsExtension.cs │ │ ├── MariaDbServerVersion.cs │ │ ├── MySqlCommonJsonChangeTrackingOptions.cs │ │ ├── MySqlDbContextOptionsBuilder.cs │ │ ├── MySqlDefaultDataTypeMappings.cs │ │ ├── MySqlSchemaBehavior.cs │ │ ├── MySqlServerVersion.cs │ │ ├── ServerType.cs │ │ ├── ServerVersion.cs │ │ └── ServerVersionSupport.cs │ ├── Internal │ │ ├── MySqlLoggerExtensions.cs │ │ ├── MySqlModelValidator.cs │ │ ├── MySqlOptions.cs │ │ └── MySqlValueGenerationStrategyCompatibility.cs │ ├── Metadata │ │ ├── Conventions │ │ │ ├── ColumnCharSetAttributeConvention.cs │ │ │ ├── ColumnCollationAttributeConvention.cs │ │ │ ├── MySqlConventionSetBuilder.cs │ │ │ ├── MySqlRuntimeModelConvention.cs │ │ │ ├── MySqlValueGenerationConvention.cs │ │ │ ├── MySqlValueGenerationStrategyConvention.cs │ │ │ ├── TableCharSetAttributeConvention.cs │ │ │ └── TableCollationAttributeConvention.cs │ │ ├── DelegationModes.cs │ │ ├── Internal │ │ │ ├── MySqlAnnotationNames.cs │ │ │ ├── MySqlAnnotationProvider.cs │ │ │ └── ObjectToEnumConverter.cs │ │ └── MySqlValueGenerationStrategy.cs │ ├── Migrations │ │ ├── Internal │ │ │ ├── MySqlHistoryRepository.cs │ │ │ ├── MySqlMigrationsModelDiffer.cs │ │ │ └── MySqlMigrator.cs │ │ ├── MySqlMigrationsSqlGenerator.cs │ │ └── Operations │ │ │ ├── DropPrimaryKeyAndRecreateForeignKeysOperation.cs │ │ │ ├── MySqlCreateDatabaseOperation.cs │ │ │ ├── MySqlDropDatabaseOperation.cs │ │ │ └── MySqlDropUniqueConstraintAndRecreateForeignKeysOperation.cs │ ├── MySqlRetryingExecutionStrategy.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── MySqlJsonStrings.Designer.cs │ │ ├── MySqlJsonStrings.Designer.tt │ │ ├── MySqlJsonStrings.resx │ │ ├── MySqlStrings.Designer.cs │ │ ├── MySqlStrings.Designer.tt │ │ └── MySqlStrings.resx │ ├── Query │ │ ├── ExpressionTranslators │ │ │ └── Internal │ │ │ │ ├── IMySqlJsonPocoTranslator.cs │ │ │ │ ├── MySqlByteArrayMethodTranslator.cs │ │ │ │ ├── MySqlConvertTranslator.cs │ │ │ │ ├── MySqlDbFunctionsExtensionsMethodTranslator.cs │ │ │ │ ├── MySqlJsonDbFunctionsTranslator.cs │ │ │ │ ├── MySqlJsonPocoTranslator.cs │ │ │ │ ├── MySqlJsonTableExpression.cs │ │ │ │ ├── MySqlRegexIsMatchTranslator.cs │ │ │ │ └── MySqlStringComparisonMethodTranslator.cs │ │ ├── ExpressionVisitors │ │ │ └── Internal │ │ │ │ ├── BitwiseOperationReturnTypeCorrectingExpressionVisitor.cs │ │ │ │ ├── MySqlBoolOptimizingExpressionVisitor.cs │ │ │ │ ├── MySqlBug96947WorkaroundExpressionVisitor.cs │ │ │ │ ├── MySqlCompatibilityExpressionVisitor.cs │ │ │ │ ├── MySqlContainsAggregateFunctionExpressionVisitor.cs │ │ │ │ ├── MySqlHavingExpressionVisitor.cs │ │ │ │ ├── MySqlJsonParameterExpressionVisitor.cs │ │ │ │ ├── MySqlNonWorkingHavingExpressionVisitor.cs │ │ │ │ ├── MySqlParameterInliningExpressionVisitor.cs │ │ │ │ ├── MySqlQuerySqlGenerator.cs │ │ │ │ ├── MySqlQuerySqlGeneratorFactory.cs │ │ │ │ ├── MySqlQueryTranslationPostprocessor.cs │ │ │ │ ├── MySqlQueryTranslationPostprocessorFactory.cs │ │ │ │ ├── MySqlQueryTranslationPreprocessor.cs │ │ │ │ ├── MySqlQueryTranslationPreprocessorFactory.cs │ │ │ │ ├── MySqlQueryableMethodNormalizingExpressionVisitor.cs │ │ │ │ ├── MySqlSqlTranslatingExpressionVisitor.cs │ │ │ │ └── MySqlSqlTranslatingExpressionVisitorFactory.cs │ │ ├── Expressions │ │ │ └── Internal │ │ │ │ ├── MySqlBinaryExpression.cs │ │ │ │ ├── MySqlBipolarExpression.cs │ │ │ │ ├── MySqlCollateExpression.cs │ │ │ │ ├── MySqlColumnAliasReferenceExpression.cs │ │ │ │ ├── MySqlComplexFunctionArgumentExpression.cs │ │ │ │ ├── MySqlInlinedParameterExpression.cs │ │ │ │ ├── MySqlJsonArrayIndexExpression.cs │ │ │ │ ├── MySqlJsonTraversalExpression.cs │ │ │ │ ├── MySqlMatchExpression.cs │ │ │ │ └── MySqlRegexpExpression.cs │ │ ├── Internal │ │ │ ├── IMySqlEvaluatableExpressionFilter.cs │ │ │ ├── MySqlCommandParser.cs │ │ │ ├── MySqlCompiledQueryCacheKeyGenerator.cs │ │ │ ├── MySqlDateDiffFunctionsTranslator.cs │ │ │ ├── MySqlDateTimeMemberTranslator.cs │ │ │ ├── MySqlDateTimeMethodTranslator.cs │ │ │ ├── MySqlEvaluatableExpressionFilter.cs │ │ │ ├── MySqlJsonMethodCallTranslatorPlugin.cs │ │ │ ├── MySqlMathMethodTranslator.cs │ │ │ ├── MySqlMemberTranslatorProvider.cs │ │ │ ├── MySqlMethodCallTranslatorProvider.cs │ │ │ ├── MySqlNewGuidTranslator.cs │ │ │ ├── MySqlObjectToStringTranslator.cs │ │ │ ├── MySqlParameterBasedSqlProcessor.cs │ │ │ ├── MySqlParameterBasedSqlProcessorFactory.cs │ │ │ ├── MySqlQueryCompilationContext.cs │ │ │ ├── MySqlQueryCompilationContextFactory.cs │ │ │ ├── MySqlQueryCompilationContextMethodTranslator.cs │ │ │ ├── MySqlQueryStringFactory.cs │ │ │ ├── MySqlQueryableMethodTranslatingExpressionVisitor.cs │ │ │ ├── MySqlQueryableMethodTranslatingExpressionVisitorFactory.cs │ │ │ ├── MySqlSqlExpressionFactory.cs │ │ │ ├── MySqlSqlNullabilityProcessor.cs │ │ │ ├── MySqlStringMemberTranslator.cs │ │ │ ├── MySqlStringMethodTranslator.cs │ │ │ ├── MySqlTimeSpanMemberTranslator.cs │ │ │ └── SkipTakeCollapsingExpressionVisitor.cs │ │ └── MySqlJsonString.cs │ ├── Scaffolding │ │ └── Internal │ │ │ ├── MySqlCodeGenerationMemberAccess.cs │ │ │ ├── MySqlCodeGenerationMemberAccessTypeMapping.cs │ │ │ ├── MySqlCodeGenerationServerVersionCreation.cs │ │ │ ├── MySqlCodeGenerationServerVersionCreationTypeMapping.cs │ │ │ ├── MySqlCodeGenerator.cs │ │ │ └── MySqlDatabaseModelFactory.cs │ ├── Storage │ │ ├── Internal │ │ │ ├── ByteArrayComparer.cs │ │ │ ├── BytesToDateTimeConverter.cs │ │ │ ├── IDefaultValueCompatibilityAware.cs │ │ │ ├── IJsonSpecificTypeMapping.cs │ │ │ ├── IMySqlCSharpRuntimeAnnotationTypeMappingCodeGenerator.cs │ │ │ ├── IMySqlConnectionStringOptionsValidator.cs │ │ │ ├── IMySqlRelationalConnection.cs │ │ │ ├── Json │ │ │ │ └── MySqlJsonByteArrayAsHexStringReaderWriter.cs │ │ │ ├── MySqlBoolTypeMapping.cs │ │ │ ├── MySqlByteArrayTypeMapping.cs │ │ │ ├── MySqlByteTypeMapping.cs │ │ │ ├── MySqlConnectionSettings.cs │ │ │ ├── MySqlConnectionStringOptionsValidator.cs │ │ │ ├── MySqlDatabaseCreator.cs │ │ │ ├── MySqlDateTimeOffsetTypeMapping.cs │ │ │ ├── MySqlDateTimeTypeMapping.cs │ │ │ ├── MySqlDateTypeMapping.cs │ │ │ ├── MySqlDecimalTypeMapping.cs │ │ │ ├── MySqlDoubleTypeMapping.cs │ │ │ ├── MySqlExecutionStrategy.cs │ │ │ ├── MySqlExecutionStrategyFactory.cs │ │ │ ├── MySqlFloatTypeMapping.cs │ │ │ ├── MySqlGuidTypeMapping.cs │ │ │ ├── MySqlIntTypeMapping.cs │ │ │ ├── MySqlJsonChangeTrackingOptions.cs │ │ │ ├── MySqlJsonTypeMapping.cs │ │ │ ├── MySqlJsonTypeMappingSourcePlugin.cs │ │ │ ├── MySqlLongTypeMapping.cs │ │ │ ├── MySqlRelationalConnection.cs │ │ │ ├── MySqlSByteTypeMapping.cs │ │ │ ├── MySqlScaffoldingConnectionSettings.cs │ │ │ ├── MySqlShortTypeMapping.cs │ │ │ ├── MySqlSqlGeneratorHelper.cs │ │ │ ├── MySqlStringTypeMapping.cs │ │ │ ├── MySqlTimeTypeMapping.cs │ │ │ ├── MySqlTransientExceptionDetector.cs │ │ │ ├── MySqlTypeMapping.cs │ │ │ ├── MySqlTypeMappingSource.cs │ │ │ ├── MySqlUIntTypeMapping.cs │ │ │ ├── MySqlULongTypeMapping.cs │ │ │ ├── MySqlUShortTypeMapping.cs │ │ │ └── MySqlYearTypeMapping.cs │ │ └── ValueComparison │ │ │ └── Internal │ │ │ └── IMySqlJsonValueComparer.cs │ ├── Update │ │ └── Internal │ │ │ ├── IMySqlUpdateSqlGenerator.cs │ │ │ ├── MySqlModificationCommand.cs │ │ │ ├── MySqlModificationCommandBatch.cs │ │ │ ├── MySqlModificationCommandBatchFactory.cs │ │ │ ├── MySqlModificationCommandFactory.cs │ │ │ └── MySqlUpdateSqlGenerator.cs │ ├── ValueGeneration │ │ └── Internal │ │ │ ├── MySqlSequentialGuidValueGenerator.cs │ │ │ └── MySqlValueGeneratorSelector.cs │ └── docs │ │ └── README.md ├── Shared │ ├── Check.cs │ ├── CodeAnnotations.cs │ ├── EnumerableExtensions.cs │ ├── MethodInfoExtensions.cs │ ├── SharedTypeExtensions.cs │ ├── Statics.cs │ ├── StringBuilderExtensions.cs │ └── TypeExtensions.cs └── stylecop.json ├── startvs.cmd ├── test ├── Directory.Build.props ├── EFCore.MySql.FunctionalTests │ ├── .gitignore │ ├── AssemblyInfo.cs │ ├── BadDataJsonDeserializationMySqlTest.cs │ ├── BuiltInDataTypesMySqlTest.cs │ ├── BulkUpdates │ │ ├── ComplexTypeBulkUpdatesMySqlTest.cs │ │ ├── NonSharedModelBulkUpdatesMySqlTest.cs │ │ ├── NorthwindBulkUpdatesMySqlFixture.cs │ │ ├── NorthwindBulkUpdatesMySqlTest.cs │ │ ├── TPCFiltersInheritanceBulkUpdatesMySqlFixture.cs │ │ ├── TPCFiltersInheritanceBulkUpdatesMySqlTest.cs │ │ ├── TPCInheritanceBulkUpdatesMySqlFixture.cs │ │ ├── TPCInheritanceBulkUpdatesMySqlTest.cs │ │ ├── TPHFiltersInheritanceBulkUpdatesMySqlFixture.cs │ │ ├── TPHFiltersInheritanceBulkUpdatesMySqlTest.cs │ │ ├── TPHInheritanceBulkUpdatesMySqlFixture.cs │ │ ├── TPHInheritanceBulkUpdatesMySqlTest.cs │ │ ├── TPTFiltersInheritanceBulkUpdatesMySqlFixture.cs │ │ ├── TPTFiltersInheritanceBulkUpdatesMySqlTest.cs │ │ ├── TPTInheritanceBulkUpdatesMySqlFixture.cs │ │ └── TPTInheritanceBulkUpdatesMySqlTest.cs │ ├── CommandInterceptionMySqlTest.cs │ ├── ComplexTypesTrackingMySqlTest.cs │ ├── CompositeKeyEndToEndMySqlTest.cs │ ├── ConcurrencyDetectorDisabledMySqlTest.cs │ ├── ConcurrencyDetectorEnabledMySqlTest.cs │ ├── ConferencePlannerMySqlTest.cs │ ├── ConnectionInterceptionMySqlTest.cs │ ├── ConnectionMySqlTest.cs │ ├── ConnectionSettingsMySqlTest.cs │ ├── ConvertToProviderTypesMySqlTest.cs │ ├── CustomConvertersMySqlTest.cs │ ├── DataAnnotationMySqlTest.cs │ ├── DatabindingMySqlTest.cs │ ├── DefaultValuesTest.cs │ ├── DesignTimeMySqlTest.cs │ ├── EFCore.MySql.FunctionalTests.csproj │ ├── EntitySplittingMySqlTest.cs │ ├── ExistingConnectionMySqlTest.cs │ ├── F1MySqlFixture.cs │ ├── FieldMappingMySqlTest.cs │ ├── FindMySqlTest.cs │ ├── FullMigrationsMySqlTest.cs │ ├── GraphUpdatesMySqlClientCascadeTest.cs │ ├── GraphUpdatesMySqlClientNoActionTest.cs │ ├── GraphUpdatesMySqlTestBase.cs │ ├── KeysWithConvertersMySqlTest.cs │ ├── LazyLoadProxyMySqlTest.cs │ ├── LoadMySqlTest.cs │ ├── LoggingMySqlTest.cs │ ├── ManyToManyLoadMySqlTest.cs │ ├── ManyToManyTrackingMySqlTest.cs │ ├── ManyToManyTrackingMySqlTestBase.cs │ ├── MaterializationInterceptionMySqlTest.cs │ ├── MigrationSqlGeneratorMySqlTest.MySql.cs │ ├── MigrationsInfrastructureMySqlTest.cs │ ├── MigrationsMySqlTest.cs │ ├── ModelBuilding │ │ ├── MySqlModelBuilderGenericTest.cs │ │ └── MySqlModelBuilderTestBase.cs │ ├── ModelBuilding101MySqlTest.cs │ ├── MonsterFixupChangedChangingMySqlTest.cs │ ├── MusicStoreMySqlTest.cs │ ├── MySqlApiConsistencyTest.cs │ ├── MySqlComplianceTest.cs │ ├── MySqlFixture.cs │ ├── MySqlMigrationsSqlGeneratorTest.cs │ ├── MySqlNetTopologySuiteApiConsistencyTest.cs │ ├── MySqlServiceCollectionExtensionsTest.cs │ ├── Northwind.sql │ ├── NorthwindQueryTaggingQueryMySqlTest.cs │ ├── NotificationEntitiesMySqlTest.cs │ ├── OptimisticConcurrencyMySqlTest.cs │ ├── OverzealousInitializationMySqlTest.cs │ ├── PropertyValuesMySqlTest.cs │ ├── ProxyGraphUpdatesMySqlTest.cs │ ├── Query │ │ ├── AdHocAdvancedMappingsQueryMySqlTest.cs │ │ ├── AdHocJsonQueryMySqlTest.cs │ │ ├── AdHocManyToManyQueryMySqlTest.cs │ │ ├── AdHocMiscellaneousQueryMySqlTest.cs │ │ ├── AdHocNavigationsQueryMySqlTest.cs │ │ ├── AdHocQueryFiltersQueryMySqlTest.cs │ │ ├── AdHocQuerySplittingQueryMySqlTest.cs │ │ ├── BoolIndexingOptimizationDisabledMySqlTest.cs │ │ ├── CaseSensitiveNorthwindQueryMySqlFixture.cs │ │ ├── CaseSensitiveWithStringComparisonNorthwindQueryMySqlFixture.cs │ │ ├── ComplexNavigationsCollectionsQueryMySqlTest.cs │ │ ├── ComplexNavigationsCollectionsSharedTypeQueryMySqlTest.cs │ │ ├── ComplexNavigationsCollectionsSplitQueryMySqlTest.cs │ │ ├── ComplexNavigationsCollectionsSplitSharedTypeQueryMySqlTest.cs │ │ ├── ComplexNavigationsQueryMySqlFixture.cs │ │ ├── ComplexNavigationsQueryMySqlTest.cs │ │ ├── ComplexNavigationsSharedTypeQueryMySqlFixture.cs │ │ ├── ComplexNavigationsSharedTypeQueryMySqlTest.cs │ │ ├── ComplexTypeQueryMySqlTest.cs │ │ ├── CompositeKeysQueryMySqlFixture.cs │ │ ├── CompositeKeysQueryMySqlTest.cs │ │ ├── CompositeKeysSplitQueryMySqlTest.cs │ │ ├── DateOnlyQueryMySqlTest.cs │ │ ├── Ef6GroupByMySqlTest.cs │ │ ├── EntitySplittingQueryMySqlTest.cs │ │ ├── EscapesMySqlNoBackslashesTest.cs │ │ ├── EscapesMySqlTest.cs │ │ ├── EscapesMySqlTestBase.cs │ │ ├── FieldsOnlyLoadMySqlTest.cs │ │ ├── FromSqlQueryMySqlTest.cs │ │ ├── FromSqlSprocQueryMySqlTest.cs │ │ ├── FunkyDataQueryMySqlTest.cs │ │ ├── GearsOfWarFromSqlQueryMySqlTest.cs │ │ ├── GearsOfWarQueryMySqlFixture.cs │ │ ├── GearsOfWarQueryMySqlTest.MySql.cs │ │ ├── GearsOfWarQueryMySqlTest.cs │ │ ├── IncludeMySqlFixture.cs │ │ ├── IncludeOneToOneMySqlTest.cs │ │ ├── InheritanceRelationshipsQueryMySqlFixture.cs │ │ ├── InheritanceRelationshipsQueryMySqlTest.cs │ │ ├── JsonMicrosoftDomChangeTrackingTest.cs │ │ ├── JsonMicrosoftDomQueryTest.cs │ │ ├── JsonMicrosoftPocoChangeTrackingTest.cs │ │ ├── JsonMicrosoftPocoQueryTest.cs │ │ ├── JsonMicrosoftStringChangeTrackingTest.cs │ │ ├── JsonMicrosoftStringQueryTest.cs │ │ ├── JsonNewtonsoftDomChangeTrackingTest.cs │ │ ├── JsonNewtonsoftDomQueryTest.cs │ │ ├── JsonNewtonsoftPocoChangeTrackingTest.cs │ │ ├── JsonNewtonsoftPocoQueryTest.cs │ │ ├── JsonNewtonsoftStringChangeTrackingTest.cs │ │ ├── JsonNewtonsoftStringQueryTest.cs │ │ ├── JsonPocoChangeTrackingTestBase.cs │ │ ├── JsonPocoQueryTestBase.cs │ │ ├── JsonStringChangeTrackingTestBase.cs │ │ ├── JsonStringQueryTestBase.cs │ │ ├── ManyToManyFieldsLoadMySqlTest.cs │ │ ├── ManyToManyNoTrackingQueryMySqlTest.cs │ │ ├── ManyToManyQueryMySqlFixture.cs │ │ ├── ManyToManyQueryMySqlTest.cs │ │ ├── MappingQueryMySqlTest.cs │ │ ├── MatchQueryMySqlTest.cs │ │ ├── NonSharedPrimitiveCollectionsQueryMySqlTest.cs │ │ ├── NorthwindAggregateOperatorsQueryMySqlTest.cs │ │ ├── NorthwindAsNoTrackingQueryMySqlTest.cs │ │ ├── NorthwindAsTrackingQueryMySqlTest.cs │ │ ├── NorthwindChangeTrackingQueryMySqlTest.cs │ │ ├── NorthwindCompiledQueryMySqlTest.cs │ │ ├── NorthwindDbFunctionsQueryMySqlTest.MySql.cs │ │ ├── NorthwindDbFunctionsQueryMySqlTest.cs │ │ ├── NorthwindEFPropertyIncludeQueryMySqlTest.cs │ │ ├── NorthwindFunctionsQueryMySqlTest.MySql.cs │ │ ├── NorthwindFunctionsQueryMySqlTest.cs │ │ ├── NorthwindGroupByQueryMySqlTest.cs │ │ ├── NorthwindIncludeNoTrackingQueryMySqlTest.cs │ │ ├── NorthwindIncludeQueryMySqlTest.cs │ │ ├── NorthwindJoinQueryMySqlTest.cs │ │ ├── NorthwindKeylessEntitiesQueryMySqlTest.cs │ │ ├── NorthwindMiscellaneousQueryMySqlTest.MySql.cs │ │ ├── NorthwindMiscellaneousQueryMySqlTest.cs │ │ ├── NorthwindQueryFiltersQueryMySqlTest.cs │ │ ├── NorthwindQueryMySqlFixture.cs │ │ ├── NorthwindSelectQueryMySqlTest.MySql.cs │ │ ├── NorthwindSelectQueryMySqlTest.cs │ │ ├── NorthwindSetOperationsQueryMySqlTest.cs │ │ ├── NorthwindSplitIncludeNoTrackingQueryMySqlTest.cs │ │ ├── NorthwindSplitIncludeQueryMySqlTest.cs │ │ ├── NorthwindSqlQueryMySqlTest.cs │ │ ├── NorthwindStringComparisonFunctionsQueryMySqlTest.cs │ │ ├── NorthwindStringIncludeQueryMySqlTest.cs │ │ ├── NorthwindWhereQueryMySqlTest.cs │ │ ├── NullKeysMySqlTest.cs │ │ ├── NullSemanticsQueryMySqlFixture.cs │ │ ├── NullSemanticsQueryMySqlTest.cs │ │ ├── OperatorsProceduralMySqlTest.cs │ │ ├── OperatorsQueryMySqlTest.cs │ │ ├── OptionalDependentQueryMySqlTest.cs │ │ ├── OptionalDependentQuerySqlServerFixture.cs │ │ ├── OwnedEntityQueryMySqlTest.cs │ │ ├── OwnedQueryMySqlTest.cs │ │ ├── PrimitiveCollectionsQueryMySqlTest.cs │ │ ├── QueryFilterFuncletizationMySqlTest.cs │ │ ├── QueryNavigationsMySqlTest.cs │ │ ├── QueryNoClientEvalMySqlFixture.cs │ │ ├── QueryNoClientEvalMySqlTest.cs │ │ ├── SharedTypeQueryMySqlTest.cs │ │ ├── SpatialGeographyQueryMySqlTest.cs │ │ ├── SpatialQueryMySqlFixture.cs │ │ ├── SpatialQueryMySqlTest.cs │ │ ├── SqlExecutorMySqlTest.cs │ │ ├── SqlQueryMySqlTest.cs │ │ ├── TPCFiltersInheritanceQueryMySqlFixture.cs │ │ ├── TPCFiltersInheritanceQueryMySqlTest.cs │ │ ├── TPCGearsOfWarQueryMySqlFixture.cs │ │ ├── TPCGearsOfWarQueryMySqlTest.cs │ │ ├── TPCInheritanceQueryMySqlFixture.cs │ │ ├── TPCInheritanceQueryMySqlTest.cs │ │ ├── TPCManyToManyNoTrackingQueryMySqlTest.cs │ │ ├── TPCManyToManyQueryMySqlFixture.cs │ │ ├── TPCManyToManyQueryMySqlTest.cs │ │ ├── TPCRelationshipsQueryMySqlTest.cs │ │ ├── TPHInheritanceQueryMySqlFixture.cs │ │ ├── TPHInheritanceQueryMySqlTest.cs │ │ ├── TPTFiltersInheritanceQueryMySqlFixture.cs │ │ ├── TPTFiltersInheritanceQueryMySqlTest.cs │ │ ├── TPTGearsOfWarQueryMySqlFixture.cs │ │ ├── TPTGearsOfWarQueryMySqlTest.cs │ │ ├── TPTInheritanceQueryMySqlFixture.cs │ │ ├── TPTInheritanceQueryMySqlTest.cs │ │ ├── TPTManyToManyNoTrackingQueryMySqlTest.cs │ │ ├── TPTManyToManyQueryMySqlFixture.cs │ │ ├── TPTManyToManyQueryMySqlTest.cs │ │ ├── TPTRelationshipsQueryMySqlTest.cs │ │ ├── ToSqlQueryMySqlTest.cs │ │ └── WarningsMySqlTest.cs │ ├── QueryExpressionInterceptionNpgsqlTestBase.cs │ ├── README.md │ ├── SaveChangesInterceptionMySqlTest.cs │ ├── Scaffolding │ │ ├── Baselines │ │ │ ├── BigModel │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DataUnsafeAccessors.cs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── DependentBaseEntityType.cs │ │ │ │ ├── DependentBaseUnsafeAccessors.cs │ │ │ │ ├── DependentDerivedEntityType.cs │ │ │ │ ├── DependentDerivedUnsafeAccessors.cs │ │ │ │ ├── ManyTypesEntityType.cs │ │ │ │ ├── ManyTypesUnsafeAccessors.cs │ │ │ │ ├── OwnedType0EntityType.cs │ │ │ │ ├── OwnedTypeEntityType.cs │ │ │ │ ├── OwnedTypeUnsafeAccessors.cs │ │ │ │ ├── PrincipalBaseEntityType.cs │ │ │ │ ├── PrincipalBasePrincipalDerivedDependentBasebyteEntityType.cs │ │ │ │ ├── PrincipalBaseUnsafeAccessors.cs │ │ │ │ ├── PrincipalDerivedEntityType.cs │ │ │ │ └── PrincipalDerivedUnsafeAccessors.cs │ │ │ ├── CheckConstraints │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DataUnsafeAccessors.cs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ └── DbContextModelBuilder.cs │ │ │ ├── ComplexTypes │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── PrincipalBaseEntityType.cs │ │ │ │ └── PrincipalDerivedEntityType.cs │ │ │ ├── Custom_function_parameter_type_mapping │ │ │ │ ├── FunctionParameterTypeMappingContextAssemblyAttributes.cs │ │ │ │ ├── FunctionParameterTypeMappingContextModel.cs │ │ │ │ └── FunctionParameterTypeMappingContextModelBuilder.cs │ │ │ ├── Custom_function_type_mapping │ │ │ │ ├── FunctionTypeMappingContextAssemblyAttributes.cs │ │ │ │ ├── FunctionTypeMappingContextModel.cs │ │ │ │ └── FunctionTypeMappingContextModelBuilder.cs │ │ │ ├── DbFunctions │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DataUnsafeAccessors.cs │ │ │ │ ├── DbFunctionContextAssemblyAttributes.cs │ │ │ │ ├── DbFunctionContextModel.cs │ │ │ │ ├── DbFunctionContextModelBuilder.cs │ │ │ │ └── ObjectEntityType.cs │ │ │ ├── Dynamic_schema │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DataUnsafeAccessors.cs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ └── DbContextModelCustomizer.cs │ │ │ ├── No_NativeAOT │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── DependentBaseEntityType.cs │ │ │ │ ├── DependentDerivedEntityType.cs │ │ │ │ ├── ManyTypesEntityType.cs │ │ │ │ ├── OwnedType0EntityType.cs │ │ │ │ ├── OwnedTypeEntityType.cs │ │ │ │ ├── PrincipalBaseEntityType.cs │ │ │ │ ├── PrincipalBasePrincipalDerivedDependentBasebyteEntityType.cs │ │ │ │ └── PrincipalDerivedEntityType.cs │ │ │ ├── Sequences │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ └── DbContextModelBuilder.cs │ │ │ ├── SimpleModel │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── DependentBaseUnsafeAccessors.cs │ │ │ │ ├── DependentDerivedEntityType.cs │ │ │ │ └── DependentDerivedUnsafeAccessors.cs │ │ │ ├── Tpc │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── DependentBaseEntityType.cs │ │ │ │ ├── PrincipalBaseEntityType.cs │ │ │ │ └── PrincipalDerivedEntityType.cs │ │ │ ├── Tpc_Sprocs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ ├── DbContextModelBuilder.cs │ │ │ │ ├── DependentBaseEntityType.cs │ │ │ │ ├── DependentBaseUnsafeAccessors.cs │ │ │ │ ├── PrincipalBaseEntityType.cs │ │ │ │ ├── PrincipalBaseUnsafeAccessors.cs │ │ │ │ ├── PrincipalDerivedEntityType.cs │ │ │ │ └── PrincipalDerivedUnsafeAccessors.cs │ │ │ └── Triggers │ │ │ │ ├── DataEntityType.cs │ │ │ │ ├── DataUnsafeAccessors.cs │ │ │ │ ├── DbContextAssemblyAttributes.cs │ │ │ │ ├── DbContextModel.cs │ │ │ │ └── DbContextModelBuilder.cs │ │ ├── CompiledModelMySqlTest.cs │ │ └── MySqlDatabaseModelFactoryTest.cs │ ├── SeedingMySqlTest.cs │ ├── SerializationMySqlTest.cs │ ├── ServiceProviderPerContextFixtureBase.cs │ ├── SpatialMySqlFixture.cs │ ├── SpatialMySqlTest.cs │ ├── Storage │ │ ├── MySqlJsonMicrosoftTypeMappingTest.cs │ │ ├── MySqlJsonNewtonsoftTypeMappingTest.cs │ │ └── MySqlTypeMappingTest.cs │ ├── StoreGeneratedFixupMySqlTest.cs │ ├── StoreGeneratedMySqlTest.cs │ ├── TPTTableSplittingMySqlTest.cs │ ├── TableSplittingMySqlTest.cs │ ├── TestModels │ │ └── Northwind │ │ │ └── NorthwindMySqlContext.cs │ ├── TestUtilities │ │ ├── DebugServices │ │ │ ├── DebugRelationalCommand.cs │ │ │ ├── DebugRelationalCommandBuilder.cs │ │ │ ├── DebugRelationalCommandBuilderFactory.cs │ │ │ └── DebugRelationalDataReader.cs │ │ ├── MySqlConnectionStringTestStoreFactory.cs │ │ ├── MySqlDatabaseCleaner.cs │ │ ├── MySqlDatabaseFacadeTestExtensions.cs │ │ ├── MySqlDbContextOptionsBuilderExtensions.cs │ │ ├── MySqlNorthwindTestStoreFactory.cs │ │ ├── MySqlTestHelpers.cs │ │ ├── MySqlTestMigrator.cs │ │ ├── MySqlTestStore.cs │ │ ├── MySqlTestStoreFactory.cs │ │ ├── TestEnvironment.cs │ │ ├── TestMySqlRetryingExecutionStrategy.cs │ │ └── Xunit │ │ │ ├── IMySqlTestClassOrderer.cs │ │ │ ├── MySqlConditionalFactDiscoverer.cs │ │ │ ├── MySqlConditionalFactTestCase.cs │ │ │ ├── MySqlConditionalTheoryDiscoverer.cs │ │ │ ├── MySqlConditionalTheoryTestCase.cs │ │ │ ├── MySqlTestCaseOrderer.cs │ │ │ ├── MySqlTestCollectionOrderer.cs │ │ │ ├── MySqlXunitTestAssemblyRunner.cs │ │ │ ├── MySqlXunitTestCaseRunner.cs │ │ │ ├── MySqlXunitTestCollectionRunner.cs │ │ │ ├── MySqlXunitTestFramework.cs │ │ │ ├── MySqlXunitTestFrameworkDiscoverer.cs │ │ │ ├── MySqlXunitTestFrameworkExecutor.cs │ │ │ ├── MySqlXunitTestRunner.cs │ │ │ └── MySqlXunitTheoryTestCaseRunner.cs │ ├── TransactionInterceptionMySqlTest.cs │ ├── TransactionMySqlTest.cs │ ├── TwoDatabasesMySqlTest.cs │ ├── Update │ │ ├── MySqlUpdateSqlGeneratorTest.cs │ │ ├── NonSharedModelUpdatesMySqlTest.cs │ │ ├── StoreValueGenerationMySqlTest.cs │ │ └── StoredProcedureUpdateMySqlTest.cs │ ├── UpdatesMySqlFixture.cs │ ├── UpdatesMySqlTest.cs │ ├── ValueConvertersEndToEndMySqlTest.cs │ ├── WithConstructorsMySqlTest.cs │ └── config.json.example ├── EFCore.MySql.IntegrationTests │ ├── .gitignore │ ├── AppDb.cs │ ├── AppDbScope.cs │ ├── Commands │ │ ├── CommandRunner.cs │ │ ├── ConnectionStringCommand.cs │ │ ├── ICommandRunner.cs │ │ ├── IConnectionStringCommand.cs │ │ ├── ITestMigrateCommand.cs │ │ ├── ITestPerformanceCommand.cs │ │ ├── ITestPerformanceRunner.cs │ │ ├── TestMigrateCommand.cs │ │ ├── TestPerformanceCommand.cs │ │ └── TestPerformanceRunner.cs │ ├── Controllers │ │ ├── AsyncController.cs │ │ └── SyncController.cs │ ├── EFCore.MySql.IntegrationTests.csproj │ ├── LegacyMigrations │ │ ├── 1.1.2 │ │ │ ├── 20170829174711_Initial.Designer.csbak │ │ │ ├── 20170829174711_Initial.csbak │ │ │ └── AppDbModelSnapshot.csbak │ │ └── 2.0.1 │ │ │ ├── 20180529213507_Initial.Designer.csbak │ │ │ ├── 20180529213507_Initial.csbak │ │ │ └── AppDbModelSnapshot.csbak │ ├── Migrations │ │ └── readme.txt │ ├── Models │ │ ├── Batch.cs │ │ ├── Blog.cs │ │ ├── Crm.cs │ │ ├── DataTypes.cs │ │ ├── GeneratedTypes.cs │ │ ├── Identity.cs │ │ ├── People.cs │ │ └── Sequence.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── README.md │ ├── Startup.cs │ ├── Tests │ │ ├── Connection │ │ │ └── ConnectionTest.cs │ │ └── Models │ │ │ ├── BatchTest.cs │ │ │ ├── CrmTest.cs │ │ │ ├── DataTypesTest.cs │ │ │ ├── DiscriminatorTest.cs │ │ │ ├── ExpressionTest.cs │ │ │ ├── GeneratedTypesTest.cs │ │ │ └── SequenceTest.cs │ ├── appsettings.ci.json │ ├── appsettings.json │ ├── config.json.example │ └── scripts │ │ ├── legacy.ps1 │ │ ├── rebuild.ps1 │ │ ├── scaffold.ps1 │ │ ├── stress.ps1 │ │ └── vegeta │ │ ├── insert1.json │ │ ├── insert2.json │ │ ├── targets-async.txt │ │ └── targets-sync.txt ├── EFCore.MySql.Tests │ ├── .gitignore │ ├── AssemblyInfo.cs │ ├── Behaviors │ │ ├── HavingBehavior.cs │ │ ├── MySql8WithSridConstraintSpatialBehavior.cs │ │ ├── MySql8WithoutSridConstraintSpatialBehavior.cs │ │ └── SpatialBehavior.cs │ ├── Bugs │ │ └── MySqlBug96947.cs │ ├── ContextBase.cs │ ├── EFCore.MySql.Tests.csproj │ ├── Migrations │ │ ├── MySqlHistoryRepositoryTest.cs │ │ ├── MySqlMigrationTest.cs │ │ └── ServerVersionTest.cs │ ├── MySqlDbContextOptionsExtensionsTest.cs │ ├── MySqlOptionsExtensionTest.cs │ ├── MySqlRelationalConnectionTest.cs │ ├── MySqlTestFixtureBase.cs │ ├── Query │ │ ├── MySqlCollationTest.cs │ │ └── MySqlTimeZoneTest.cs │ ├── TestBase.cs │ ├── TestUtilities │ │ ├── BuildFileResult.cs │ │ ├── BuildReference.cs │ │ ├── BuildSource.cs │ │ ├── FakeProvider │ │ │ └── FakeRelationalOptionsExtension.cs │ │ ├── ListDiagnosticSource.cs │ │ ├── TestProviderCodeGenerator.cs │ │ ├── TestRelationalConventionSetBuilder.cs │ │ ├── TestRelationalMigrationSqlGenerator.cs │ │ └── TestRelationalTypeMappingSource.cs │ ├── TestWithFixture.cs │ ├── ValueGeneration │ │ └── Internal │ │ │ └── MysqlSequentialGuidValueGeneratorTest.cs │ ├── config.json.example │ └── dotnet-run.sh ├── Shared │ ├── AppConfig.cs │ └── TestUtilities │ │ └── Attributes │ │ ├── SupportedServerVersionBetweenConditionAttribute.cs │ │ ├── SupportedServerVersionConditionAttribute.cs │ │ └── SupportedServerVersionLessThanConditionAttribute.cs └── xunit.runner.json └── tools ├── QueryBaselineUpdater ├── Program.cs └── QueryBaselineUpdater.csproj └── Resources.tt /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.cs diff=csharp 3 | *.csbak diff=csharp 4 | *.sh eol=lf 5 | *.sln eol=crlf 6 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Can be changed to /.github/workflows/ if necessary. 2 | /.github/ @PomeloFoundation/CIAdmin -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ['lauxjpn'] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | Ideally include a complete source code listing that we can run to reproduce the issue. 16 | Alternatively, provide a project/solution that we can run. 17 | In most cases, we need at least a couple of lines of code to reproduce a bug. 18 | Always post code as text (never as a screenshot). 19 | 20 | **Expected behavior** 21 | In case it is not obvious from the bug description, please provide a clear and concise description of what you expected to happen. 22 | 23 | **Technical details (please complete the following information):** 24 | 25 | - Database server version: [e.g. MySQL 8.0.41 or MariaDB 11.6.2] 26 | - Operating system: [e.g. Windows 11 or Ubuntu 22.04.5 LTS] 27 | - Pomelo.EntityFrameworkCore.MySql version: [e.g. 8.0.3 or 9.0.0-preview.3.efcore.9.0.0] 28 | - Other technical details: [e.g. ASP.NET Core, AWS Lambda, etc.] 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/24a3b5bb2c0ac6839e5035eba1925dff4ac6140a/.github/PULL_REQUEST_TEMPLATE.md -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceRoot}/test/EFCore.MySql.IntegrationTests/bin/Debug/netcoreapp2.0/Pomelo.EntityFrameworkCore.MySql.FunctionalTests.dll", 14 | "args": [], 15 | "cwd": "${workspaceRoot}/test/EFCore.MySql.IntegrationTests", 16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window 17 | "console": "internalConsole", 18 | "stopAtEntry": false, 19 | "internalConsoleOptions": "openOnSessionStart" 20 | }, 21 | { 22 | "name": ".NET Core Attach", 23 | "type": "coreclr", 24 | "request": "attach", 25 | "processId": "${command:pickProcess}" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "build", 9 | "args": [ 10 | "${workspaceRoot}/test/EFCore.MySql.IntegrationTests/EFCore.MySql.IntegrationTests.csproj" 11 | ], 12 | "isBuildCommand": true, 13 | "problemMatcher": "$msCompile" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /Development.props.sample: -------------------------------------------------------------------------------- 1 | <Project> 2 | <PropertyGroup> 3 | <!-- 4 | Specify the absolute path to the EntityFrameworkCore base directory, 5 | to compile against that version for better development and local 6 | debugging support. 7 | 8 | Rename this file to "development.props". 9 | 10 | The EFCore assemblies are being compiled with an AssemblyVersion of 11 | "42.42.42.42" by default. To not get any compilation errors 12 | for the EFCore.MySql.IntegrationTests project, that uses 13 | Microsoft.AspNetCore.Identity.EntityFrameworkCore, which references 14 | it's own version of EFCore, you have to make sure that your local 15 | EFCore assemblies are compiled with an AssemblyVersion <= the one 16 | referenced by Microsoft.AspNetCore.Identity.EntityFrameworkCore 17 | (e.g. "6.0.0.0"). 18 | 19 | To achive that, run the following command in your EntityFrameworkCore 20 | base directory: 21 | 22 | dotnet build "/p:AssemblyVersion=6.0.0.0" 23 | --> 24 | <LocalEFCoreRepository>C:\Repositories\EntityFrameworkCore</LocalEFCoreRepository> 25 | <LocalMySqlConnectorRepository>C:\Repositories\MySqlConnector</LocalMySqlConnectorRepository> 26 | </PropertyGroup> 27 | </Project> -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Pomelo Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <configuration> 3 | <packageSources> 4 | <add key="pomelo-nightly-public-azdo" value="https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-public/nuget/v3/index.json" /> 5 | <add key="pomelo-nightly-debug-azdo" value="https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-debug/nuget/v3/index.json" /> 6 | <add key="pomelo-nightly-public-myget" value="https://www.myget.org/F/pomelo/api/v3/index.json" /> 7 | <add key="pomelo-nightly-debug-myget" value="https://www.myget.org/F/pomelo-debug/api/v3/index.json" /> 8 | 9 | <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> 10 | <add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" /> 11 | <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" /> 12 | </packageSources> 13 | <packageSourceMapping> 14 | <packageSource key="nuget.org"> 15 | <package pattern="*" /> 16 | </packageSource> 17 | </packageSourceMapping> 18 | </configuration> 19 | -------------------------------------------------------------------------------- /Pomelo.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/24a3b5bb2c0ac6839e5035eba1925dff4ac6140a/Pomelo.snk -------------------------------------------------------------------------------- /dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "9.0.0", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "9.0.100", 4 | "allowPrerelease": false, 5 | "rollForward": "latestFeature" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/24a3b5bb2c0ac6839e5035eba1925dff4ac6140a/icon.png -------------------------------------------------------------------------------- /rulesets/Documentation.ruleset: -------------------------------------------------------------------------------- 1 | <?xml version="1.0"?> 2 | <RuleSet Name="DocumentationAnalyzers" Description="DocumentationAnalyzers" ToolsVersion="15.0"> 3 | <Rules AnalyzerId="DocumentationAnalyzers" RuleNamespace="DocumentationAnalyzers"> 4 | <Rule Id="DOC100" Action="None" /> <!-- PlaceTextInParagraphs --> 5 | <Rule Id="DOC101" Action="Warning" /> <!-- UseChildBlocksConsistently --> 6 | <Rule Id="DOC102" Action="None" /> <!-- UseChildBlocksConsistentlyAcrossElementsOfTheSameKind --> 7 | <Rule Id="DOC103" Action="Warning" /> <!-- UseUnicodeCharacters --> 8 | <Rule Id="DOC104" Action="Warning" /> <!-- UseSeeLangword --> 9 | <Rule Id="DOC105" Action="Warning" /> <!-- UseParamref --> 10 | <Rule Id="DOC106" Action="Warning" /> <!-- UseTypeparamref --> 11 | <Rule Id="DOC107" Action="Warning" /> <!-- UseSeeCref --> 12 | <Rule Id="DOC108" Action="Warning" /> <!-- AvoidEmptyParagraphs --> 13 | <Rule Id="DOC200" Action="Warning" /> <!-- UseXmlDocumentationSyntax --> 14 | <Rule Id="DOC201" Action="Warning" /> <!-- ItemShouldHaveDescription --> 15 | <Rule Id="DOC202" Action="Warning" /> <!-- UseSectionElementsCorrectly --> 16 | <Rule Id="DOC203" Action="Warning" /> <!-- UseBlockElementsCorrectly --> 17 | <Rule Id="DOC204" Action="Warning" /> <!-- UseInlineElementsCorrectly --> 18 | <Rule Id="DOC207" Action="Warning" /> <!-- UseSeeLangwordCorrectly --> 19 | <Rule Id="DOC209" Action="Warning" /> <!-- UseSeeHrefCorrectly --> 20 | </Rules> 21 | </RuleSet> 22 | -------------------------------------------------------------------------------- /rulesets/EFCore.ruleset: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <RuleSet Name="EFCore" ToolsVersion="15.0"> 3 | <Include Path="StyleCop.ruleset" Action="Default" /> 4 | <Include Path="FxCop.ruleset" Action="Default" /> 5 | <Include Path="Documentation.ruleset" Action="Default" /> 6 | </RuleSet> 7 | -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | <Project> 2 | <Import Project="..\Directory.Build.props" /> 3 | 4 | <PropertyGroup> 5 | <!-- [CS1591] Missing XML comment for publicly visible type or member 'MySqlAnnotationCodeGenerator' --> 6 | <NoWarn>$(NoWarn);CS1591;EF1001</NoWarn> 7 | <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\rulesets\EFCore.ruleset</CodeAnalysisRuleSet> 8 | <GenerateDocumentationFile>True</GenerateDocumentationFile> 9 | </PropertyGroup> 10 | 11 | <ItemGroup> 12 | <PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" PrivateAssets="All" /> 13 | </ItemGroup> 14 | 15 | <PropertyGroup> 16 | <IsPackable>true</IsPackable> 17 | <IncludeSymbols>true</IncludeSymbols> 18 | <EmbedUntrackedSources>true</EmbedUntrackedSources> 19 | <SymbolPackageFormat>snupkg</SymbolPackageFormat> 20 | <AllowedOutputExtensionsInPackageBuildOutputFolder Condition="'$(PackPdb)' == 'true'">$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> 21 | </PropertyGroup> 22 | 23 | <ItemGroup> 24 | <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" /> 25 | </ItemGroup> 26 | </Project> 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Extensions/MySqlJsonMicrosoftPropertyExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Extensions.Internal; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Extensions 10 | { 11 | /// <summary> 12 | /// Extension methods for <see cref="IProperty" /> for MySQL-specific metadata. 13 | /// </summary> 14 | public static class MySqlJsonMicrosoftPropertyExtensions 15 | { 16 | /// <summary> 17 | /// Sets specific change tracking options for this JSON property, that specify how inner properties or array 18 | /// elements will be tracked. Applies to simple strings, POCOs and DOM objects. Using `null` restores all 19 | /// defaults. 20 | /// </summary> 21 | /// <param name="property">The JSON property to set the change tracking options for.</param> 22 | /// <param name="options">The change tracking option to configure for the JSON property.</param> 23 | public static void SetJsonChangeTrackingOptions([NotNull] this IMutableProperty property, MySqlCommonJsonChangeTrackingOptions? options) 24 | => property.SetJsonChangeTrackingOptions(options?.ToJsonChangeTrackingOptions()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Query/Internal/MySqlJsonMicrosoftPocoTranslator.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Text.Json.Serialization; 3 | using JetBrains.Annotations; 4 | using Microsoft.EntityFrameworkCore.Query; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | using Pomelo.EntityFrameworkCore.MySql.Query.ExpressionTranslators.Internal; 7 | using Pomelo.EntityFrameworkCore.MySql.Query.Internal; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Query.Internal 10 | { 11 | public class MySqlJsonMicrosoftPocoTranslator : MySqlJsonPocoTranslator 12 | { 13 | public MySqlJsonMicrosoftPocoTranslator( 14 | [NotNull] IRelationalTypeMappingSource typeMappingSource, 15 | [NotNull] ISqlExpressionFactory sqlExpressionFactory) 16 | : base(typeMappingSource, (MySqlSqlExpressionFactory)sqlExpressionFactory) 17 | { 18 | } 19 | 20 | public override string GetJsonPropertyName(MemberInfo member) 21 | => member.GetCustomAttribute<JsonPropertyNameAttribute>()?.Name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Scaffolding/Internal/MySqlJsonMicrosoftCodeGeneratorPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.EntityFrameworkCore; 7 | using Microsoft.EntityFrameworkCore.Design; 8 | using Microsoft.EntityFrameworkCore.Infrastructure; 9 | using Microsoft.EntityFrameworkCore.Scaffolding; 10 | 11 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Scaffolding.Internal 12 | { 13 | public class MySqlJsonMicrosoftCodeGeneratorPlugin : ProviderCodeGeneratorPlugin 14 | { 15 | private static readonly MethodInfo _useMicrosoftJsonMethodInfo = 16 | typeof(MySqlJsonMicrosoftDbContextOptionsBuilderExtensions).GetRequiredRuntimeMethod( 17 | nameof(MySqlJsonMicrosoftDbContextOptionsBuilderExtensions.UseMicrosoftJson), 18 | typeof(MySqlDbContextOptionsBuilder), 19 | typeof(MySqlCommonJsonChangeTrackingOptions)); 20 | 21 | public override MethodCallCodeFragment GenerateProviderOptions() 22 | => new MethodCallCodeFragment(_useMicrosoftJsonMethodInfo); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Storage/ValueConversion/Internal/MySqlJsonMicrosoftJsonDocumentValueConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Text.Json; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | // ReSharper disable once CheckNamespace 10 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Storage.ValueConversion.Internal 11 | { 12 | public class MySqlJsonMicrosoftJsonDocumentValueConverter : ValueConverter<JsonDocument, string> 13 | { 14 | public MySqlJsonMicrosoftJsonDocumentValueConverter() 15 | : base( 16 | v => ConvertToProviderCore(v), 17 | v => ConvertFromProviderCore(v)) 18 | { 19 | } 20 | 21 | public static string ConvertToProviderCore(JsonDocument v) 22 | { 23 | using var stream = new MemoryStream(); 24 | using var writer = new Utf8JsonWriter(stream); 25 | v.WriteTo(writer); 26 | writer.Flush(); 27 | return Encoding.UTF8.GetString(stream.ToArray()); 28 | } 29 | 30 | public static JsonDocument ConvertFromProviderCore(string v) 31 | => JsonDocument.Parse(v); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Storage/ValueConversion/Internal/MySqlJsonMicrosoftJsonElementValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using System.Text.Json; 4 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Storage.ValueConversion.Internal 8 | { 9 | public class MySqlJsonMicrosoftJsonElementValueConverter : ValueConverter<JsonElement, string> 10 | { 11 | public MySqlJsonMicrosoftJsonElementValueConverter() 12 | : base( 13 | v => ConvertToProviderCore(v), 14 | v => ConvertFromProviderCore(v)) 15 | { 16 | } 17 | 18 | public static string ConvertToProviderCore(JsonElement v) 19 | { 20 | using var stream = new MemoryStream(); 21 | using var writer = new Utf8JsonWriter(stream); 22 | v.WriteTo(writer); 23 | writer.Flush(); 24 | return Encoding.UTF8.GetString(stream.ToArray()); 25 | } 26 | 27 | public static JsonElement ConvertFromProviderCore(string v) 28 | => JsonDocument.Parse(v).RootElement; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Storage/ValueConversion/Internal/MySqlJsonMicrosoftPocoValueConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Text.Json; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Storage.ValueConversion.Internal 9 | { 10 | public class MySqlJsonMicrosoftPocoValueConverter<T> : ValueConverter<T, string> 11 | { 12 | public MySqlJsonMicrosoftPocoValueConverter() 13 | : base( 14 | v => ConvertToProviderCore(v), 15 | v => ConvertFromProviderCore(v)) 16 | { 17 | } 18 | 19 | public static string ConvertToProviderCore(T v) 20 | => JsonSerializer.Serialize(v); 21 | 22 | public static T ConvertFromProviderCore(string v) 23 | => JsonSerializer.Deserialize<T>(v); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/Storage/ValueConversion/Internal/MySqlJsonMicrosoftStringValueConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Text.Json; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | // ReSharper disable once CheckNamespace 10 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Microsoft.Storage.ValueConversion.Internal 11 | { 12 | public class MySqlJsonMicrosoftStringValueConverter : ValueConverter<string, string> 13 | { 14 | public MySqlJsonMicrosoftStringValueConverter() 15 | : base( 16 | v => ConvertToProviderCore(v), 17 | v => ConvertFromProviderCore(v)) 18 | { 19 | } 20 | 21 | public static string ConvertToProviderCore(string v) 22 | => ProcessJsonString(v); 23 | 24 | public static string ConvertFromProviderCore(string v) 25 | => ProcessJsonString(v); 26 | 27 | internal static string ProcessJsonString(string v) 28 | { 29 | using var stream = new MemoryStream(); 30 | using var writer = new Utf8JsonWriter(stream); 31 | JsonDocument.Parse(v) 32 | .WriteTo(writer); 33 | writer.Flush(); 34 | return Encoding.UTF8.GetString(stream.ToArray()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Microsoft/docs/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | _Pomelo.EntityFrameworkCore.MySql.Json.Microsoft_ adds JSON support for `System.Text.Json` (the Microsoft JSON stack) to [Pomelo.EntityFrameworkCore.MySql](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). 4 | 5 | ## How to Use 6 | 7 | ```csharp 8 | optionsBuilder.UseMySql( 9 | connectionString, 10 | serverVersion, 11 | options => options.UseMicrosoftJson()) 12 | ``` 13 | 14 | ## Related Packages 15 | 16 | * [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql) 17 | * [System.Text.Json](https://www.nuget.org/packages/System.Text.Json) 18 | 19 | ## License 20 | 21 | _Pomelo.EntityFrameworkCore.MySql.Json.Microsoft_ is released as open source under the [MIT license](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/main/LICENSE). 22 | 23 | ## Feedback 24 | 25 | Bug reports and contributions are welcome at our [GitHub repository](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Extensions/MySqlJsonNewtonsoftPropertyExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Extensions.Internal; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Extensions 10 | { 11 | /// <summary> 12 | /// Extension methods for <see cref="IProperty" /> for MySQL-specific metadata. 13 | /// </summary> 14 | public static class MySqlJsonNewtonsoftPropertyExtensions 15 | { 16 | /// <summary> 17 | /// Sets specific change tracking options for this JSON property, that specify how inner properties or array 18 | /// elements will be tracked. Applies to simple strings, POCOs and DOM objects. Using `null` restores all 19 | /// defaults. 20 | /// </summary> 21 | /// <param name="property">The JSON property to set the change tracking options for.</param> 22 | /// <param name="options">The change tracking option to configure for the JSON property.</param> 23 | public static void SetJsonChangeTrackingOptions([NotNull] this IMutableProperty property, MySqlCommonJsonChangeTrackingOptions? options) 24 | => property.SetJsonChangeTrackingOptions(options?.ToJsonChangeTrackingOptions()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Query/Internal/MySqlJsonNewtonsoftPocoTranslator.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using JetBrains.Annotations; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using Newtonsoft.Json; 6 | using Pomelo.EntityFrameworkCore.MySql.Query.ExpressionTranslators.Internal; 7 | using Pomelo.EntityFrameworkCore.MySql.Query.Internal; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Query.Internal 10 | { 11 | public class MySqlJsonNewtonsoftPocoTranslator : MySqlJsonPocoTranslator 12 | { 13 | public MySqlJsonNewtonsoftPocoTranslator( 14 | [NotNull] IRelationalTypeMappingSource typeMappingSource, 15 | [NotNull] ISqlExpressionFactory sqlExpressionFactory) 16 | : base(typeMappingSource, (MySqlSqlExpressionFactory)sqlExpressionFactory) 17 | { 18 | } 19 | 20 | public override string GetJsonPropertyName(MemberInfo member) 21 | => member.GetCustomAttribute<JsonPropertyAttribute>()?.PropertyName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Scaffolding/Internal/MySqlJsonNewtonsoftCodeGeneratorPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.EntityFrameworkCore; 7 | using Microsoft.EntityFrameworkCore.Design; 8 | using Microsoft.EntityFrameworkCore.Infrastructure; 9 | using Microsoft.EntityFrameworkCore.Scaffolding; 10 | 11 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Scaffolding.Internal 12 | { 13 | public class MySqlJsonNewtonsoftCodeGeneratorPlugin : ProviderCodeGeneratorPlugin 14 | { 15 | private static readonly MethodInfo _useNewtonsoftJsonMethodInfo = 16 | typeof(MySqlJsonNewtonsoftDbContextOptionsBuilderExtensions).GetRequiredRuntimeMethod( 17 | nameof(MySqlJsonNewtonsoftDbContextOptionsBuilderExtensions.UseNewtonsoftJson), 18 | typeof(MySqlDbContextOptionsBuilder), 19 | typeof(MySqlCommonJsonChangeTrackingOptions)); 20 | 21 | public override MethodCallCodeFragment GenerateProviderOptions() 22 | => new MethodCallCodeFragment(_useNewtonsoftJsonMethodInfo); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Storage/ValueConversion/Internal/MySqlJsonNewtonsoftJTokenValueConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Linq; 7 | 8 | // ReSharper disable once CheckNamespace 9 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Storage.ValueConversion.Internal 10 | { 11 | public class MySqlJsonNewtonsoftJTokenValueConverter : ValueConverter<JToken, string> 12 | { 13 | public MySqlJsonNewtonsoftJTokenValueConverter() 14 | : base( 15 | v => ConvertToProviderCore(v), 16 | v => ConvertFromProviderCore(v)) 17 | { 18 | } 19 | 20 | private static string ConvertToProviderCore(JToken v) 21 | => v.ToString(Formatting.None); 22 | 23 | private static JToken ConvertFromProviderCore(string v) 24 | => JToken.Parse(v); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Storage/ValueConversion/Internal/MySqlJsonNewtonsoftPocoValueConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 5 | using Newtonsoft.Json; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Storage.ValueConversion.Internal 9 | { 10 | public class MySqlJsonNewtonsoftPocoValueConverter<T> : ValueConverter<T, string> 11 | { 12 | public MySqlJsonNewtonsoftPocoValueConverter() 13 | : base( 14 | v => ConvertToProviderCore(v), 15 | v => ConvertFromProviderCore(v)) 16 | { 17 | } 18 | 19 | private static string ConvertToProviderCore(T v) 20 | => JsonConvert.SerializeObject(v); 21 | 22 | private static T ConvertFromProviderCore(string v) 23 | => JsonConvert.DeserializeObject<T>(v); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/Storage/ValueConversion/Internal/MySqlJsonNewtonsoftStringValueConverter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | 5 | // ReSharper disable once CheckNamespace 6 | namespace Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft.Storage.ValueConversion.Internal 7 | { 8 | public class MySqlJsonNewtonsoftStringValueConverter : ValueConverter<string, string> 9 | { 10 | public MySqlJsonNewtonsoftStringValueConverter() 11 | : base( 12 | v => ConvertToProviderCore(v), 13 | v => ConvertFromProviderCore(v)) 14 | { 15 | } 16 | 17 | private static string ConvertToProviderCore(string v) 18 | => ProcessJsonString(v); 19 | 20 | private static string ConvertFromProviderCore(string v) 21 | => ProcessJsonString(v); 22 | 23 | internal static string ProcessJsonString(string v) 24 | => JToken.Parse(v).ToString(Formatting.None); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql.Json.Newtonsoft/docs/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | _Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft_ adds JSON support for `Newtonsoft.Json` (the Newtonsoft JSON/Json.NET stack) to [Pomelo.EntityFrameworkCore.MySql](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). 4 | 5 | ## How to Use 6 | 7 | ```csharp 8 | optionsBuilder.UseMySql( 9 | connectionString, 10 | serverVersion, 11 | options => options.UseNewtonsoftJson()) 12 | ``` 13 | 14 | ## Related Packages 15 | 16 | * [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql) 17 | * [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json) 18 | 19 | ## License 20 | 21 | _Pomelo.EntityFrameworkCore.MySql.Json.Newtonsoft_ is released as open source under the [MIT license](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/main/LICENSE). 22 | 23 | ## Feedback 24 | 25 | Bug reports and contributions are welcome at our [GitHub repository](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). -------------------------------------------------------------------------------- /src/EFCore.MySql.NTS/Properties/MySqlNTSStrings.Designer.tt: -------------------------------------------------------------------------------- 1 | <# 2 | Session["ResourceFile"] = "MySqlNTSStrings.resx"; 3 | Session["LoggingDefinitionsClass"] = "MySqlNtsLoggingDefinitions"; 4 | Session["NoDiagnostics"] = true; 5 | #> 6 | <#@ include file="..\..\..\tools\Resources.tt" #> -------------------------------------------------------------------------------- /src/EFCore.MySql.NTS/Query/Internal/MySqlNetTopologySuiteEvaluatableExpressionFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 6 | { 7 | public class MySqlNetTopologySuiteEvaluatableExpressionFilter : IMySqlEvaluatableExpressionFilter 8 | { 9 | public virtual bool? IsEvaluatableExpression(Expression expression, IModel model) 10 | { 11 | if (expression is MethodCallExpression methodCallExpression && 12 | methodCallExpression.Method.DeclaringType == typeof(MySqlSpatialDbFunctionsExtensions)) 13 | { 14 | return false; 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/EFCore.MySql.NTS/Scaffolding/Internal/MySqlNetTopologySuiteCodeGeneratorPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.EntityFrameworkCore; 7 | using Microsoft.EntityFrameworkCore.Design; 8 | using Microsoft.EntityFrameworkCore.Infrastructure; 9 | using Microsoft.EntityFrameworkCore.Scaffolding; 10 | 11 | namespace Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal 12 | { 13 | public class MySqlNetTopologySuiteCodeGeneratorPlugin : ProviderCodeGeneratorPlugin 14 | { 15 | private static readonly MethodInfo _useNetTopologySuiteMethodInfo = 16 | typeof(MySqlNetTopologySuiteDbContextOptionsBuilderExtensions).GetRequiredRuntimeMethod( 17 | nameof(MySqlNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite), 18 | typeof(MySqlDbContextOptionsBuilder)); 19 | 20 | public override MethodCallCodeFragment GenerateProviderOptions() 21 | => new MethodCallCodeFragment(_useNetTopologySuiteMethodInfo); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql.NTS/docs/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | _Pomelo.EntityFrameworkCore.MySql.NetTopologySuite_ adds spatial support for [NetTopologySuite](https://github.com/NetTopologySuite/NetTopologySuite) to [Pomelo.EntityFrameworkCore.MySql](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). 4 | 5 | ## How to Use 6 | 7 | ```csharp 8 | optionsBuilder.UseMySql( 9 | connectionString, 10 | serverVersion, 11 | options => options.UseNetTopologySuite()) 12 | ``` 13 | 14 | ## Related Packages 15 | 16 | * [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql) 17 | * [NetTopologySuite](https://www.nuget.org/packages/NetTopologySuite) 18 | 19 | ## License 20 | 21 | _Pomelo.EntityFrameworkCore.MySql.NetTopologySuite_ is released as open source under the [MIT license](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/main/LICENSE). 22 | 23 | ## Feedback 24 | 25 | Bug reports and contributions are welcome at our [GitHub repository](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql). -------------------------------------------------------------------------------- /src/EFCore.MySql/Design/Internal/MySqlDesignTimeServices.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal; 5 | using Microsoft.EntityFrameworkCore.Design; 6 | using Microsoft.EntityFrameworkCore.Design.Internal; 7 | using Microsoft.EntityFrameworkCore.Scaffolding; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Pomelo.EntityFrameworkCore.MySql.Design.Internal 11 | { 12 | public class MySqlDesignTimeServices : IDesignTimeServices 13 | { 14 | public virtual void ConfigureDesignTimeServices(IServiceCollection serviceCollection) 15 | { 16 | serviceCollection.AddEntityFrameworkMySql(); 17 | new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection) 18 | .TryAdd<ICSharpRuntimeAnnotationCodeGenerator, MySqlCSharpRuntimeAnnotationCodeGenerator>() 19 | .TryAdd<IAnnotationCodeGenerator, MySqlAnnotationCodeGenerator>() 20 | .TryAdd<IDatabaseModelFactory, MySqlDatabaseModelFactory>() 21 | .TryAdd<IProviderConfigurationCodeGenerator, MySqlCodeGenerator>() 22 | .TryAddCoreServices(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/DbDataReaderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Linq; 5 | using JetBrains.Annotations; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace System.Data.Common 9 | { 10 | internal static class DbDataReaderExtension 11 | { 12 | public static T GetValueOrDefault<T>([NotNull] this DbDataReader reader, [NotNull] string name) 13 | { 14 | var idx = reader.GetOrdinal(name); 15 | return reader.IsDBNull(idx) 16 | ? default 17 | : reader.GetFieldValue<T>(idx); 18 | } 19 | 20 | public static bool HasName(this DbDataReader reader, string columnName) 21 | => Enumerable.Range(0, reader.FieldCount) 22 | .Any(i => string.Equals(reader.GetName(i), columnName, StringComparison.OrdinalIgnoreCase)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/DbDataRecordExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace System.Data.Common 8 | { 9 | internal static class DbDataRecordExtensions 10 | { 11 | /// <summary> 12 | /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to 13 | /// the same compatibility standards as public APIs. It may be changed or removed without notice in 14 | /// any release. You should only use it directly in your code with extreme caution and knowing that 15 | /// doing so can result in application failures when updating to a new Entity Framework Core release. 16 | /// </summary> 17 | public static T GetValueOrDefault<T>([NotNull] this DbDataRecord record, [NotNull] string name) 18 | { 19 | var idx = record.GetOrdinal(name); 20 | return record.IsDBNull(idx) 21 | ? default 22 | : (T)record.GetValue(idx); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/IEnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace System.Linq 9 | { 10 | // ReSharper disable once InconsistentNaming 11 | internal static class IEnumerableExtensions 12 | { 13 | internal static IEnumerable<T> AppendIfTrue<T>(this IEnumerable<T> source, bool condition, Func<T> elementGetter) 14 | => condition 15 | ? source.Append(elementGetter.Invoke()) 16 | : source; 17 | 18 | internal static IEnumerable<T> AppendIfTrue<T>(this IEnumerable<T> source, bool condition, T element) 19 | => condition 20 | ? source.Append(element) 21 | : source; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/MySqlDbFunctionsEnums.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | namespace Microsoft.EntityFrameworkCore 5 | { 6 | public enum MySqlMatchSearchMode 7 | { 8 | /// <summary> 9 | /// Perform a natural language search for a string against a text collection. 10 | /// </summary> 11 | NaturalLanguage = 0, 12 | 13 | /// <summary> 14 | /// Perform a natural language search with query expansion for a string against a text collection. 15 | /// </summary> 16 | NaturalLanguageWithQueryExpansion = 1, 17 | 18 | /// <summary> 19 | /// Perform a boolean search for a string against a text collection. 20 | /// </summary> 21 | Boolean = 2, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/MySqlKeyBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 6 | using Microsoft.EntityFrameworkCore.Utilities; 7 | 8 | // ReSharper disable once CheckNamespace 9 | namespace Microsoft.EntityFrameworkCore 10 | { 11 | public static class MySqlKeyBuilderExtensions 12 | { 13 | /// <summary> 14 | /// Sets prefix lengths for the key. 15 | /// </summary> 16 | /// <param name="keyBuilder"> The key builder. </param> 17 | /// <param name="prefixLengths">The prefix lengths to set, in the order the key columns where specified. 18 | /// A value of `0` indicates, that the full length should be used for that column. </param> 19 | /// <returns> The key builder. </returns> 20 | public static KeyBuilder HasPrefixLength([NotNull] this KeyBuilder keyBuilder, params int[] prefixLengths) 21 | { 22 | Check.NotNull(keyBuilder, nameof(keyBuilder)); 23 | 24 | keyBuilder.Metadata.SetPrefixLength(prefixLengths); 25 | 26 | return keyBuilder; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.Extensions 5 | { 6 | internal static class StringExtensions 7 | { 8 | internal static string NullIfEmpty(this string value) 9 | => value?.Length > 0 10 | ? value 11 | : null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Infrastructure/MySqlSchemaBehavior.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.Infrastructure 5 | { 6 | public delegate string MySqlSchemaNameTranslator(string schemaName, string objectName); 7 | 8 | public enum MySqlSchemaBehavior 9 | { 10 | /// <summary> 11 | /// Throw an exception if a schema is being used. Any specified translator delegate will be ignored. 12 | /// This is the default. 13 | /// </summary> 14 | Throw, 15 | 16 | /// <summary> 17 | /// Silently ignore any schema definitions. Any specified translator delegate will be ignored. 18 | /// </summary> 19 | Ignore, 20 | 21 | /// <summary> 22 | /// Use the specified translator delegate to translate from an input schema and object name to 23 | /// an output object name whenever a schema is being used. 24 | /// </summary> 25 | Translate, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Infrastructure/ServerType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.Infrastructure 5 | { 6 | public enum ServerType 7 | { 8 | /// <summary> 9 | /// Custom server implementation 10 | /// </summary> 11 | Custom = -1, 12 | 13 | /// <summary> 14 | /// MySQL server 15 | /// </summary> 16 | MySql, 17 | 18 | /// <summary> 19 | /// MariaDB server 20 | /// </summary> 21 | MariaDb 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Metadata/DelegationModes.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Microsoft.EntityFrameworkCore 8 | { 9 | /// <summary> 10 | /// Provides precice control over recursive character set or collation delegation/inheritance aspects. 11 | /// </summary> 12 | [Flags] 13 | public enum DelegationModes 14 | { 15 | /// <summary> 16 | /// The current default is <see cref="ApplyToAll"/>. 17 | /// </summary> 18 | Default = 0, 19 | 20 | /// <summary> 21 | /// Applys the character set or collation to databases. 22 | /// </summary> 23 | ApplyToDatabases = 1 << 0, 24 | 25 | /// <summary> 26 | /// Applys the character set or collation to tables. 27 | /// </summary> 28 | ApplyToTables = 1 << 1, 29 | 30 | /// <summary> 31 | /// Applys the character set or collation to columns. 32 | /// </summary> 33 | ApplyToColumns = 1 << 2, 34 | 35 | /// <summary> 36 | /// Applys the character set or collation to all objects. 37 | /// </summary> 38 | ApplyToAll = ApplyToDatabases | ApplyToTables | ApplyToColumns 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Metadata/Internal/ObjectToEnumConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Metadata.Internal 7 | { 8 | public static class ObjectToEnumConverter 9 | { 10 | /// <summary> 11 | /// Can be used to allow substitution of enum values with their underlying type in annotations, so that multi-provider models can 12 | /// be setup without provider specific dependencies. 13 | /// </summary> 14 | /// <remarks> 15 | /// See https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1205 for further information. 16 | /// </remarks> 17 | public static T? GetEnumValue<T>(object value) 18 | where T : struct 19 | => value != null && 20 | Enum.IsDefined(typeof(T), value) 21 | ? (T?)(T)Enum.ToObject(typeof(T), value) 22 | : null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Metadata/MySqlValueGenerationStrategy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | //ReSharper disable once CheckNamespace 5 | namespace Microsoft.EntityFrameworkCore.Metadata 6 | { 7 | // ReSharper disable once SA1602 8 | public enum MySqlValueGenerationStrategy 9 | { 10 | /// <summary> 11 | /// TODO 12 | /// </summary> 13 | None, 14 | 15 | /// <summary> 16 | /// TODO 17 | /// </summary> 18 | IdentityColumn, 19 | 20 | /// <summary> 21 | /// TODO 22 | /// </summary> 23 | ComputedColumn // TODO: Remove this and only use .HasComputedColumnSql() instead in EF Core 5 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Migrations/Operations/DropPrimaryKeyAndRecreateForeignKeysOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Microsoft.EntityFrameworkCore.Migrations.Operations 8 | { 9 | /// <summary> 10 | /// A <see cref="MigrationOperation" /> for dropping a primary key. 11 | /// </summary> 12 | [DebuggerDisplay("ALTER TABLE {Table} DROP CONSTRAINT {Name}")] 13 | public class MySqlDropPrimaryKeyAndRecreateForeignKeysOperation : DropPrimaryKeyOperation 14 | { 15 | /// <summary> 16 | /// Recreate all foreign keys or not. 17 | /// </summary> 18 | public virtual bool RecreateForeignKeys { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Migrations/Operations/MySqlCreateDatabaseOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Microsoft.EntityFrameworkCore.Migrations.Operations 8 | { 9 | /// <summary> 10 | /// A MySql Server-specific <see cref="MigrationOperation" /> to create a database. 11 | /// </summary> 12 | public class MySqlCreateDatabaseOperation : DatabaseOperation 13 | { 14 | /// <summary> 15 | /// The name of the database. 16 | /// </summary> 17 | public virtual string Name { get; [param: NotNull] set; } 18 | 19 | /// <summary> 20 | /// The default character set of the database. 21 | /// </summary> 22 | public virtual string CharSet { get; [param: CanBeNull] set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Migrations/Operations/MySqlDropDatabaseOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Microsoft.EntityFrameworkCore.Migrations.Operations 8 | { 9 | /// <summary> 10 | /// A MySql Server-specific <see cref="MigrationOperation" /> to drop a database. 11 | /// </summary> 12 | public class MySqlDropDatabaseOperation : MigrationOperation 13 | { 14 | /// <summary> 15 | /// The name of the database. 16 | /// </summary> 17 | public virtual string Name { get; [param: NotNull] set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Migrations/Operations/MySqlDropUniqueConstraintAndRecreateForeignKeysOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Microsoft.EntityFrameworkCore.Migrations.Operations 8 | { 9 | /// <summary> 10 | /// A <see cref="MigrationOperation" /> for dropping a primary key. 11 | /// </summary> 12 | [DebuggerDisplay("ALTER TABLE {Table} DROP CONSTRAINT {Name}")] 13 | public class MySqlDropUniqueConstraintAndRecreateForeignKeysOperation : DropUniqueConstraintOperation 14 | { 15 | /// <summary> 16 | /// Recreate all foreign keys or not. 17 | /// </summary> 18 | public virtual bool RecreateForeignKeys { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | using Microsoft.EntityFrameworkCore.Design; 6 | 7 | [assembly: DesignTimeProviderServices("Pomelo.EntityFrameworkCore.MySql.Design.Internal.MySqlDesignTimeServices")] 8 | [assembly: InternalsVisibleTo("Pomelo.EntityFrameworkCore.MySql.FunctionalTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001002d40e2372e6f611238ace2bf7c80546c03a568c471495b6c91b89de694de5413b25ac77a005a371c46f15ab87f13d49ec7aa9bbd9fa99d8f51deb1d87c42d81047aa118519d9813bd5973e8cc8d17d8e5e5e865bce62518aa46e2348dac3db3638b00b9a8df69e1158e4ea82913b6a14c19c07fe473e7511ce91c1b7f41155cf")] 9 | [assembly: InternalsVisibleTo("Pomelo.EntityFrameworkCore.MySql.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001002d40e2372e6f611238ace2bf7c80546c03a568c471495b6c91b89de694de5413b25ac77a005a371c46f15ab87f13d49ec7aa9bbd9fa99d8f51deb1d87c42d81047aa118519d9813bd5973e8cc8d17d8e5e5e865bce62518aa46e2348dac3db3638b00b9a8df69e1158e4ea82913b6a14c19c07fe473e7511ce91c1b7f41155cf")] 10 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Properties/MySqlJsonStrings.Designer.tt: -------------------------------------------------------------------------------- 1 | <# 2 | Session["ResourceFile"] = "MySqlJsonStrings.resx"; 3 | Session["LoggingDefinitionsClass"] = "MySqlJsonLoggingDefinitions"; 4 | Session["NoDiagnostics"] = true; 5 | #> 6 | <#@ include file="..\..\..\tools\Resources.tt" #> -------------------------------------------------------------------------------- /src/EFCore.MySql/Properties/MySqlStrings.Designer.tt: -------------------------------------------------------------------------------- 1 | <# 2 | Session["ResourceFile"] = "MySqlStrings.resx"; 3 | Session["LoggingDefinitionsClass"] = "Diagnostics.Internal.MySqlLoggingDefinitions"; 4 | #> 5 | <#@ include file="..\..\..\tools\Resources.tt" #> -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/ExpressionTranslators/Internal/IMySqlJsonPocoTranslator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using JetBrains.Annotations; 7 | using Microsoft.EntityFrameworkCore.Query; 8 | using Microsoft.EntityFrameworkCore.Query.SqlExpressions; 9 | 10 | namespace Pomelo.EntityFrameworkCore.MySql.Query.ExpressionTranslators.Internal 11 | { 12 | public interface IMySqlJsonPocoTranslator : IMemberTranslator 13 | { 14 | SqlExpression TranslateMemberAccess([NotNull] SqlExpression instance, [NotNull] SqlExpression member, [NotNull] Type returnType); 15 | SqlExpression TranslateArrayLength([NotNull] SqlExpression expression); 16 | string GetJsonPropertyName([CanBeNull] MemberInfo member); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlQuerySqlGeneratorFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Query; 6 | using Microsoft.EntityFrameworkCore.Storage; 7 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Query.ExpressionVisitors.Internal 10 | { 11 | public class MySqlQuerySqlGeneratorFactory : IQuerySqlGeneratorFactory 12 | { 13 | private readonly QuerySqlGeneratorDependencies _dependencies; 14 | private readonly IRelationalTypeMappingSource _typeMappingSource; 15 | private readonly IMySqlOptions _options; 16 | 17 | public MySqlQuerySqlGeneratorFactory( 18 | [NotNull] QuerySqlGeneratorDependencies dependencies, 19 | IRelationalTypeMappingSource typeMappingSource, 20 | IMySqlOptions options) 21 | { 22 | _dependencies = dependencies; 23 | _typeMappingSource = typeMappingSource; 24 | _options = options; 25 | } 26 | 27 | public virtual QuerySqlGenerator Create() 28 | => new MySqlQuerySqlGenerator(_dependencies, _typeMappingSource, _options); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlQueryTranslationPreprocessorFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Query; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Query.ExpressionVisitors.Internal; 7 | 8 | public class MySqlQueryTranslationPreprocessorFactory : IQueryTranslationPreprocessorFactory 9 | { 10 | private readonly QueryTranslationPreprocessorDependencies _dependencies; 11 | private readonly RelationalQueryTranslationPreprocessorDependencies _relationalDependencies; 12 | 13 | public MySqlQueryTranslationPreprocessorFactory( 14 | QueryTranslationPreprocessorDependencies dependencies, 15 | RelationalQueryTranslationPreprocessorDependencies relationalDependencies) 16 | { 17 | _dependencies = dependencies; 18 | _relationalDependencies = relationalDependencies; 19 | } 20 | 21 | public virtual QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext) 22 | => new MySqlQueryTranslationPreprocessor( 23 | _dependencies, 24 | _relationalDependencies, 25 | queryCompilationContext); 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/IMySqlEvaluatableExpressionFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Linq.Expressions; 5 | using JetBrains.Annotations; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 9 | { 10 | public interface IMySqlEvaluatableExpressionFilter 11 | { 12 | /// <summary> 13 | /// Checks whether the given expression can be evaluated. 14 | /// </summary> 15 | /// <param name="expression"> The expression. </param> 16 | /// <param name="model"> The model. </param> 17 | /// <returns> 18 | /// <see langword="true" /> if the expression can be evaluated, <see langword="false" /> if it can't and <see langword="null" /> if 19 | /// it doesn't handle the given expression. 20 | /// </returns> 21 | bool? IsEvaluatableExpression([NotNull] Expression expression, [NotNull] IModel model); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/MySqlMemberTranslatorProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Query; 6 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 9 | { 10 | public class MySqlMemberTranslatorProvider : RelationalMemberTranslatorProvider 11 | { 12 | public MySqlMemberTranslatorProvider([NotNull] RelationalMemberTranslatorProviderDependencies dependencies, IMySqlOptions mySqlOptions) 13 | : base(dependencies) 14 | { 15 | var sqlExpressionFactory = (MySqlSqlExpressionFactory)dependencies.SqlExpressionFactory; 16 | 17 | AddTranslators( 18 | new IMemberTranslator[] { 19 | new MySqlDateTimeMemberTranslator(sqlExpressionFactory, mySqlOptions), 20 | new MySqlStringMemberTranslator(sqlExpressionFactory), 21 | new MySqlTimeSpanMemberTranslator(sqlExpressionFactory), 22 | }); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/MySqlParameterBasedSqlProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Query; 6 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 9 | { 10 | public class MySqlParameterBasedSqlProcessorFactory : IRelationalParameterBasedSqlProcessorFactory 11 | { 12 | private readonly RelationalParameterBasedSqlProcessorDependencies _dependencies; 13 | [NotNull] private readonly IMySqlOptions _options; 14 | 15 | public MySqlParameterBasedSqlProcessorFactory( 16 | [NotNull] RelationalParameterBasedSqlProcessorDependencies dependencies, 17 | [NotNull] IMySqlOptions options) 18 | { 19 | _dependencies = dependencies; 20 | _options = options; 21 | } 22 | 23 | public virtual RelationalParameterBasedSqlProcessor Create(RelationalParameterBasedSqlProcessorParameters parameters) 24 | => new MySqlParameterBasedSqlProcessor(_dependencies, parameters, _options); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Query; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 8 | { 9 | public class MySqlQueryCompilationContext : RelationalQueryCompilationContext 10 | { 11 | public MySqlQueryCompilationContext( 12 | [NotNull] QueryCompilationContextDependencies dependencies, 13 | [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, bool async) 14 | : base(dependencies, relationalDependencies, async) 15 | { 16 | } 17 | 18 | public override bool IsBuffering 19 | => base.IsBuffering || 20 | QuerySplittingBehavior == Microsoft.EntityFrameworkCore.QuerySplittingBehavior.SplitQuery; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContextFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Query; 6 | using Microsoft.EntityFrameworkCore.Utilities; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 9 | { 10 | public class MySqlQueryCompilationContextFactory : IQueryCompilationContextFactory 11 | { 12 | private readonly QueryCompilationContextDependencies _dependencies; 13 | private readonly RelationalQueryCompilationContextDependencies _relationalDependencies; 14 | 15 | public MySqlQueryCompilationContextFactory( 16 | [NotNull] QueryCompilationContextDependencies dependencies, 17 | [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies) 18 | { 19 | Check.NotNull(dependencies, nameof(dependencies)); 20 | Check.NotNull(relationalDependencies, nameof(relationalDependencies)); 21 | 22 | _dependencies = dependencies; 23 | _relationalDependencies = relationalDependencies; 24 | } 25 | 26 | public virtual QueryCompilationContext Create(bool async) 27 | => new MySqlQueryCompilationContext(_dependencies, _relationalDependencies, async); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Query/Internal/MySqlStringMemberTranslator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.EntityFrameworkCore; 7 | using Microsoft.EntityFrameworkCore.Diagnostics; 8 | using Microsoft.EntityFrameworkCore.Query; 9 | using Microsoft.EntityFrameworkCore.Query.SqlExpressions; 10 | 11 | namespace Pomelo.EntityFrameworkCore.MySql.Query.Internal 12 | { 13 | public class MySqlStringMemberTranslator : IMemberTranslator 14 | { 15 | private readonly MySqlSqlExpressionFactory _sqlExpressionFactory; 16 | 17 | public MySqlStringMemberTranslator(MySqlSqlExpressionFactory sqlExpressionFactory) 18 | { 19 | _sqlExpressionFactory = sqlExpressionFactory; 20 | } 21 | 22 | public virtual SqlExpression Translate( 23 | SqlExpression instance, 24 | MemberInfo member, 25 | Type returnType, 26 | IDiagnosticsLogger<DbLoggerCategory.Query> logger) 27 | { 28 | if (member.Name == nameof(string.Length) 29 | && member.DeclaringType == typeof(string)) 30 | { 31 | return _sqlExpressionFactory.NullableFunction( 32 | "CHAR_LENGTH", 33 | new[] { instance }, 34 | returnType); 35 | } 36 | 37 | return null; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Scaffolding/Internal/MySqlCodeGenerationMemberAccess.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Reflection; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal 7 | { 8 | internal class MySqlCodeGenerationMemberAccess 9 | { 10 | public MemberInfo MemberInfo { get; } 11 | 12 | public MySqlCodeGenerationMemberAccess(MemberInfo memberInfo) 13 | { 14 | MemberInfo = memberInfo; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Scaffolding/Internal/MySqlCodeGenerationServerVersionCreation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore; 5 | using Pomelo.EntityFrameworkCore.MySql.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal 8 | { 9 | internal class MySqlCodeGenerationServerVersionCreation 10 | { 11 | public ServerVersion ServerVersion { get; } 12 | 13 | public MySqlCodeGenerationServerVersionCreation(ServerVersion serverVersion) 14 | { 15 | ServerVersion = serverVersion; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/ByteArrayComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Collections; 5 | using System.Linq; 6 | using Microsoft.EntityFrameworkCore.ChangeTracking; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 9 | { 10 | public class ByteArrayComparer : ValueComparer<byte[]> 11 | { 12 | public ByteArrayComparer() 13 | : base( 14 | (v1, v2) => StructuralComparisons.StructuralEqualityComparer.Equals(v1, v2), 15 | v => StructuralComparisons.StructuralEqualityComparer.GetHashCode(v), 16 | v => v == null ? null : v.ToArray()) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/BytesToDateTimeConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 8 | { 9 | public class BytesToDateTimeConverter : ValueConverter<byte[], DateTime> 10 | { 11 | private static readonly NumberToBytesConverter<long> _longToBytes 12 | = new NumberToBytesConverter<long>(); 13 | 14 | public BytesToDateTimeConverter() 15 | : base( 16 | v => FromBytes(v), 17 | v => ToBytes(v)) 18 | { 19 | } 20 | 21 | public static byte[] ToBytes(DateTime v) 22 | => (byte[])_longToBytes.ConvertToProvider(v.ToBinary()); 23 | 24 | public static DateTime FromBytes(byte[] v) 25 | => DateTime.FromBinary((long)_longToBytes.ConvertFromProvider(v)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/IDefaultValueCompatibilityAware.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 7 | { 8 | public interface IDefaultValueCompatibilityAware 9 | { 10 | /// <summary> 11 | /// Creates a copy of this mapping. 12 | /// </summary> 13 | /// <param name="isDefaultValueCompatible"> Use a default value compatible syntax, or not. </param> 14 | /// <returns> The newly created mapping. </returns> 15 | RelationalTypeMapping Clone(bool isDefaultValueCompatible = false); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/IJsonSpecificTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 7 | 8 | public interface IJsonSpecificTypeMapping 9 | { 10 | RelationalTypeMapping CloneAsJsonCompatible(); 11 | } 12 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/IMySqlCSharpRuntimeAnnotationTypeMappingCodeGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Design.Internal; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 7 | 8 | public interface IMySqlCSharpRuntimeAnnotationTypeMappingCodeGenerator 9 | { 10 | void Create( 11 | CSharpRuntimeAnnotationCodeGeneratorParameters codeGeneratorParameters, 12 | CSharpRuntimeAnnotationCodeGeneratorDependencies codeGeneratorDependencies); 13 | } 14 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/IMySqlConnectionStringOptionsValidator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Data.Common; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public interface IMySqlConnectionStringOptionsValidator 10 | { 11 | bool EnsureMandatoryOptions(ref string connectionString); 12 | bool EnsureMandatoryOptions(DbConnection connection); 13 | bool EnsureMandatoryOptions(DbDataSource dataSource); 14 | 15 | void ThrowException(Exception innerException = null); 16 | } 17 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/IMySqlRelationalConnection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 7 | { 8 | /// <summary> 9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used 10 | /// directly from your code. This API may change or be removed in future releases. 11 | /// </summary> 12 | public interface IMySqlRelationalConnection : IRelationalConnection 13 | { 14 | /// <summary> 15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used 16 | /// directly from your code. This API may change or be removed in future releases. 17 | /// </summary> 18 | IMySqlRelationalConnection CreateMasterConnection(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/Json/MySqlJsonByteArrayAsHexStringReaderWriter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using System.Linq.Expressions; 6 | using System.Reflection; 7 | using System.Text.Json; 8 | using Microsoft.EntityFrameworkCore.Storage.Json; 9 | 10 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal.Json; 11 | 12 | public sealed class MySqlJsonByteArrayAsHexStringReaderWriter : JsonValueReaderWriter<byte[]> 13 | { 14 | public static readonly PropertyInfo InstanceProperty = 15 | typeof(MySqlJsonByteArrayAsHexStringReaderWriter).GetProperty(nameof(Instance)); 16 | 17 | public static MySqlJsonByteArrayAsHexStringReaderWriter Instance { get; } = new(); 18 | 19 | private MySqlJsonByteArrayAsHexStringReaderWriter() 20 | { 21 | } 22 | 23 | public override byte[] FromJsonTyped(ref Utf8JsonReaderManager manager, object existingObject = null) 24 | => Convert.FromHexString(manager.CurrentReader.GetString()!); 25 | 26 | public override void ToJsonTyped(Utf8JsonWriter writer, byte[] value) 27 | => writer.WriteStringValue(Convert.ToHexString(value)); 28 | 29 | public override Expression ConstructorExpression 30 | => Expression.Property(null, InstanceProperty); 31 | } 32 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlByteTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlByteTypeMapping : ByteTypeMapping 10 | { 11 | public static new MySqlByteTypeMapping Default { get; } = new("tinyint unsigned"); 12 | 13 | public MySqlByteTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.Byte) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlByteTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlByteTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlIntTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlIntTypeMapping : IntTypeMapping 10 | { 11 | public static new MySqlIntTypeMapping Default { get; } = new("int"); 12 | 13 | public MySqlIntTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.Int32) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlIntTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlIntTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlLongTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlLongTypeMapping : LongTypeMapping 10 | { 11 | public static new MySqlLongTypeMapping Default { get; } = new("bigint"); 12 | 13 | public MySqlLongTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.Int64) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlLongTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlLongTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlSByteTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlSByteTypeMapping : SByteTypeMapping 10 | { 11 | public static new MySqlSByteTypeMapping Default { get; } = new("tinyint"); 12 | 13 | public MySqlSByteTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.SByte) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlSByteTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlSByteTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlShortTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlShortTypeMapping : ShortTypeMapping 10 | { 11 | public static new MySqlShortTypeMapping Default { get; } = new("smallint"); 12 | 13 | public MySqlShortTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.Int16) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlShortTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlShortTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlTransientExceptionDetector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System; 5 | using JetBrains.Annotations; 6 | using MySqlConnector; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 9 | { 10 | /// <summary> 11 | /// Detects the exceptions caused by MySQL transient failures. 12 | /// </summary> 13 | public static class MySqlTransientExceptionDetector 14 | { 15 | /// <summary> 16 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used 17 | /// directly from your code. This API may change or be removed in future releases. 18 | /// </summary> 19 | public static bool ShouldRetryOn([NotNull] Exception ex) 20 | => ex is MySqlException mySqlException 21 | ? mySqlException.IsTransient 22 | : ex is TimeoutException; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlUIntTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlUIntTypeMapping : UIntTypeMapping 10 | { 11 | public static new MySqlUIntTypeMapping Default { get; } = new("int unsigned"); 12 | 13 | public MySqlUIntTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.UInt32) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlUIntTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlUIntTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlULongTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlULongTypeMapping : ULongTypeMapping 10 | { 11 | public static new MySqlULongTypeMapping Default { get; } = new("bigint unsigned"); 12 | 13 | public MySqlULongTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.UInt64) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlULongTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlULongTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlUShortTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Data; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 8 | 9 | public class MySqlUShortTypeMapping : UShortTypeMapping 10 | { 11 | public static new MySqlUShortTypeMapping Default { get; } = new("smallint unsigned"); 12 | 13 | public MySqlUShortTypeMapping( 14 | string storeType, 15 | DbType? dbType = System.Data.DbType.UInt16) 16 | : base(storeType, dbType) 17 | { 18 | } 19 | 20 | protected MySqlUShortTypeMapping(RelationalTypeMappingParameters parameters) 21 | : base(parameters) 22 | { 23 | } 24 | 25 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 26 | => new MySqlUShortTypeMapping(parameters); 27 | } 28 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/Internal/MySqlYearTypeMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.EntityFrameworkCore.Storage; 6 | using Microsoft.EntityFrameworkCore.Storage.Json; 7 | using MySqlConnector; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.Internal 10 | { 11 | public class MySqlYearTypeMapping : MySqlTypeMapping 12 | { 13 | public static MySqlYearTypeMapping Default { get; } = new("year"); 14 | 15 | public MySqlYearTypeMapping([NotNull] string storeType) 16 | : base( 17 | storeType, 18 | typeof(short), 19 | MySqlDbType.Year, 20 | System.Data.DbType.Int16, 21 | jsonValueReaderWriter: JsonInt16ReaderWriter.Instance) 22 | { 23 | } 24 | 25 | protected MySqlYearTypeMapping(RelationalTypeMappingParameters parameters, MySqlDbType mySqlDbType) 26 | : base(parameters, mySqlDbType) 27 | { 28 | } 29 | 30 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters) 31 | => new MySqlYearTypeMapping(parameters, MySqlDbType); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Storage/ValueComparison/Internal/IMySqlJsonValueComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.ChangeTracking; 5 | using Pomelo.EntityFrameworkCore.MySql.Storage.Internal; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.Storage.ValueComparison.Internal 8 | { 9 | public interface IMySqlJsonValueComparer 10 | { 11 | ValueComparer Clone(MySqlJsonChangeTrackingOptions options); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Update/Internal/IMySqlUpdateSqlGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using JetBrains.Annotations; 7 | using Microsoft.EntityFrameworkCore.Update; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.Update.Internal 10 | { 11 | public interface IMySqlUpdateSqlGenerator : IUpdateSqlGenerator 12 | { 13 | ResultSetMapping AppendBulkInsertOperation( 14 | [NotNull] StringBuilder commandStringBuilder, 15 | [NotNull] IReadOnlyList<IReadOnlyModificationCommand> modificationCommands, 16 | int commandPosition, 17 | out bool requiresTransaction); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/EFCore.MySql/Update/Internal/MySqlModificationCommandFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using Microsoft.EntityFrameworkCore.Update; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.Update.Internal; 7 | 8 | public class MySqlModificationCommandFactory : IModificationCommandFactory 9 | { 10 | public virtual IModificationCommand CreateModificationCommand( 11 | in ModificationCommandParameters modificationCommandParameters) 12 | => new MySqlModificationCommand(modificationCommandParameters); 13 | 14 | public virtual INonTrackedModificationCommand CreateNonTrackedModificationCommand( 15 | in NonTrackedModificationCommandParameters modificationCommandParameters) 16 | => new MySqlModificationCommand(modificationCommandParameters); 17 | } 18 | -------------------------------------------------------------------------------- /src/Shared/MethodInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Diagnostics; 5 | using JetBrains.Annotations; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace System.Reflection 9 | { 10 | [DebuggerStepThrough] 11 | internal static class MethodInfoExtensions 12 | { 13 | internal static bool IsClosedFormOf( 14 | [NotNull] this MethodInfo methodInfo, [NotNull] MethodInfo genericMethod) 15 | => methodInfo.IsGenericMethod 16 | && Equals( 17 | methodInfo.GetGenericMethodDefinition(), 18 | genericMethod); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Shared/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Pomelo Foundation. All rights reserved. 2 | // Licensed under the MIT. See LICENSE in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | #nullable enable 7 | 8 | // ReSharper disable once CheckNamespace 9 | namespace System.Reflection 10 | { 11 | internal static class TypeExtensions 12 | { 13 | internal static bool IsGenericList(this Type type) 14 | => type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>); 15 | 16 | internal static bool IsArrayOrGenericList(this Type type) 17 | => type.IsArray || type.IsGenericList(); 18 | 19 | internal static bool TryGetElementType(this Type type, out Type? elementType) 20 | { 21 | elementType = type.IsArray 22 | ? type.GetElementType() 23 | : type.IsGenericList() 24 | ? type.GetGenericArguments()[0] 25 | : null; 26 | return elementType != null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "documentationRules": { 5 | "companyName": "Pomelo Foundation", 6 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the MIT. See LICENSE in the project root for license information.", 7 | "xmlHeader": false, 8 | "documentInterfaces": false, 9 | "documentInternalElements": false 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /startvs.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | :: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK. 4 | 5 | :: This tells .NET Core to use .dotnet\dotnet.exe 6 | SET DOTNET_ROOT=%~dp0.dotnet\ 7 | 8 | :: This tells .NET Core not to go looking for .NET Core in other places 9 | SET DOTNET_MULTILEVEL_LOOKUP=0 10 | 11 | :: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use 12 | SET PATH=%DOTNET_ROOT%;%PATH% 13 | 14 | SET sln=%1 15 | 16 | IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" ( 17 | call restore.cmd 18 | ) 19 | 20 | echo ProTip^: You can drag and drop a solution file onto startvs.cmd 21 | 22 | IF "%sln%"=="" ( 23 | echo Error^: Expected argument ^<SLN_FILE^> 24 | echo Usage^: startvs.cmd ^<SLN_FILE^> 25 | 26 | exit /b 1 27 | ) 28 | 29 | start %sln% 30 | -------------------------------------------------------------------------------- /test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | <Project> 2 | <Import Project="..\Directory.Build.props" /> 3 | 4 | <PropertyGroup> 5 | <NoWarn>$(NoWarn);EF1001;MSB3277;xUnit1000</NoWarn> 6 | </PropertyGroup> 7 | 8 | <ItemGroup> 9 | <PackageReference Include="Microsoft.NET.Test.Sdk" /> 10 | <!-- Using xunit.core and .assert instead of the main package because compilation fails due to warnings triggered by xunit.analyzers. --> 11 | <!-- <PackageReference Include="xunit" /> --> 12 | <PackageReference Include="xunit.core" /> 13 | <PackageReference Include="xunit.assert" /> 14 | <PackageReference Include="xunit.runner.visualstudio" /> 15 | <PackageReference Include="xunit.runner.console" /> 16 | <PackageReference Include="GitHubActionsTestLogger" /> 17 | <PackageReference Include="Xunit.SkippableFact" /> 18 | </ItemGroup> 19 | </Project> 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/.gitignore: -------------------------------------------------------------------------------- 1 | /config.json 2 | /.vscode 3 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | // 4 | // Optional: Control the test execution order. 5 | // This can be helpful for diffing etc. 6 | // 7 | 8 | #if FIXED_TEST_ORDER || SPECIFIC_TEST_ORDER 9 | 10 | [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true, MaxParallelThreads = 1)] 11 | [assembly: TestCaseOrderer("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlTestCaseOrderer", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 12 | [assembly: TestCollectionOrderer("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlTestCollectionOrderer", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 13 | 14 | #endif 15 | 16 | // Our custom MySqlXunitTestFrameworkDiscoverer class allows filtering whole classes like SupportedServerVersionConditionAttribute, instead 17 | // of just the test cases. This is necessary, if a fixture is database server version dependent. 18 | [assembly: TestFramework("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlXunitTestFramework", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 19 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BadDataJsonDeserializationMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Pomelo.EntityFrameworkCore.MySql.Tests; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; 5 | 6 | public class BadDataJsonDeserializationMySqlTest : BadDataJsonDeserializationTestBase 7 | { 8 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 9 | => base.OnConfiguring(optionsBuilder.UseMySql(AppConfig.ServerVersion, b => b.UseNetTopologySuite())); 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.BulkUpdates; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestModels.Northwind; 6 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 9 | 10 | public class NorthwindBulkUpdatesMySqlFixture<TModelCustomizer> : NorthwindBulkUpdatesRelationalFixture<TModelCustomizer> 11 | where TModelCustomizer : ITestModelCustomizer, new() 12 | { 13 | protected override ITestStoreFactory TestStoreFactory 14 | => MySqlNorthwindTestStoreFactory.Instance; 15 | 16 | protected override Type ContextType 17 | => typeof(NorthwindMySqlContext); 18 | } 19 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 2 | 3 | public class TPCFiltersInheritanceBulkUpdatesMySqlFixture : TPCInheritanceBulkUpdatesMySqlFixture 4 | { 5 | protected override string StoreName 6 | => "TPCFiltersInheritanceBulkUpdatesTest"; 7 | 8 | public override bool EnableFilters 9 | => true; 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 2 | 3 | public class TPHFiltersInheritanceBulkUpdatesMySqlFixture : TPHInheritanceBulkUpdatesMySqlFixture 4 | { 5 | protected override string StoreName 6 | => "FiltersInheritanceBulkUpdatesTest"; 7 | 8 | public override bool EnableFilters 9 | => true; 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.BulkUpdates; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 6 | 7 | public class TPHInheritanceBulkUpdatesMySqlFixture : TPHInheritanceBulkUpdatesFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 2 | 3 | public class TPTFiltersInheritanceBulkUpdatesMySqlFixture : TPTInheritanceBulkUpdatesMySqlFixture 4 | { 5 | protected override string StoreName 6 | => "TPTFiltersInheritanceBulkUpdatesTest"; 7 | 8 | public override bool EnableFilters 9 | => true; 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.BulkUpdates; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; 6 | 7 | public class TPTInheritanceBulkUpdatesMySqlFixture : TPTInheritanceBulkUpdatesFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/CompositeKeyEndToEndMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class CompositeKeyEndToEndMySqlTest : CompositeKeyEndToEndTestBase<CompositeKeyEndToEndMySqlTest.CompositeKeyEndToEndMySqlFixture> 8 | { 9 | public CompositeKeyEndToEndMySqlTest(CompositeKeyEndToEndMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class CompositeKeyEndToEndMySqlFixture : CompositeKeyEndToEndFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/ConcurrencyDetectorEnabledMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.TestUtilities; 6 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 7 | using Xunit; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 10 | { 11 | public class ConcurrencyDetectorEnabledMySqlTest : ConcurrencyDetectorEnabledRelationalTestBase< 12 | ConcurrencyDetectorEnabledMySqlTest.ConcurrencyDetectorMySqlFixture> 13 | { 14 | public ConcurrencyDetectorEnabledMySqlTest(ConcurrencyDetectorMySqlFixture fixture) 15 | : base(fixture) 16 | { 17 | Fixture.TestSqlLoggerFactory.Clear(); 18 | } 19 | 20 | protected override async Task ConcurrencyDetectorTest(Func<ConcurrencyDetectorDbContext, Task<object>> test) 21 | { 22 | await base.ConcurrencyDetectorTest(test); 23 | 24 | Assert.Empty(Fixture.TestSqlLoggerFactory.SqlStatements); 25 | } 26 | 27 | public class ConcurrencyDetectorMySqlFixture : ConcurrencyDetectorFixtureBase 28 | { 29 | protected override ITestStoreFactory TestStoreFactory 30 | => MySqlTestStoreFactory.Instance; 31 | 32 | public TestSqlLoggerFactory TestSqlLoggerFactory 33 | => (TestSqlLoggerFactory)ListLoggerFactory; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/DatabindingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 4 | { 5 | public class DatabindingMySqlTest : DataBindingTestBase<F1MySqlFixture> 6 | { 7 | public DatabindingMySqlTest(F1MySqlFixture fixture) 8 | : base(fixture) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/DesignTimeMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using Pomelo.EntityFrameworkCore.MySql.Design.Internal; 5 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class DesignTimeMySqlTest : DesignTimeTestBase<DesignTimeMySqlTest.DesignTimeMySqlFixture> 10 | { 11 | public DesignTimeMySqlTest(DesignTimeMySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | protected override Assembly ProviderAssembly 17 | => typeof(MySqlDesignTimeServices).Assembly; 18 | 19 | public class DesignTimeMySqlFixture : DesignTimeFixtureBase 20 | { 21 | protected override ITestStoreFactory TestStoreFactory 22 | => MySqlTestStoreFactory.Instance; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/EntitySplittingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | using Xunit.Abstractions; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; 7 | 8 | public class EntitySplittingMySqlTest : EntitySplittingTestBase 9 | { 10 | public EntitySplittingMySqlTest(ITestOutputHelper testOutputHelper) 11 | : base(testOutputHelper) 12 | { 13 | } 14 | 15 | protected override ITestStoreFactory TestStoreFactory 16 | => MySqlTestStoreFactory.Instance; 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/F1MySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class F1MySqlFixture : F1MySqlFixture<byte[]> 8 | { 9 | } 10 | 11 | public abstract class F1MySqlFixture<TRowVersion> : F1RelationalFixture<TRowVersion> 12 | { 13 | protected override ITestStoreFactory TestStoreFactory 14 | => MySqlTestStoreFactory.Instance; 15 | 16 | public override TestHelpers TestHelpers 17 | => MySqlTestHelpers.Instance; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/FieldMappingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using Microsoft.EntityFrameworkCore.TestUtilities; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class FieldMappingMySqlTest : FieldMappingTestBase<FieldMappingMySqlTest.FieldMappingMySqlFixture> 10 | { 11 | public FieldMappingMySqlTest(FieldMappingMySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) 17 | => facade.UseTransaction(transaction.GetDbTransaction()); 18 | 19 | public class FieldMappingMySqlFixture : FieldMappingFixtureBase 20 | { 21 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/KeysWithConvertersMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | using Pomelo.EntityFrameworkCore.MySql.Tests; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 7 | { 8 | public class KeysWithConvertersMySqlTest : KeysWithConvertersTestBase< 9 | KeysWithConvertersMySqlTest.KeysWithConvertersMySqlFixture> 10 | { 11 | public KeysWithConvertersMySqlTest(KeysWithConvertersMySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | public class KeysWithConvertersMySqlFixture : KeysWithConvertersFixtureBase 17 | { 18 | protected override ITestStoreFactory TestStoreFactory 19 | => MySqlTestStoreFactory.Instance; 20 | 21 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 22 | => builder.UseMySql(AppConfig.ServerVersion, b => b.MinBatchSize(1)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/LoadMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Diagnostics; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 7 | { 8 | public class LoadMySqlTest : LoadTestBase<LoadMySqlTest.LoadMySqlFixture> 9 | { 10 | public LoadMySqlTest(LoadMySqlFixture fixture) 11 | : base(fixture) 12 | { 13 | } 14 | 15 | public class LoadMySqlFixture : LoadFixtureBase 16 | { 17 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 18 | 19 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 20 | => base.AddOptions(builder); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/ManyToManyTrackingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 2 | { 3 | public class ManyToManyTrackingMySqlTest 4 | : ManyToManyTrackingMySqlTestBase<ManyToManyTrackingMySqlTest.ManyToManyTrackingMySqlFixture> 5 | { 6 | public ManyToManyTrackingMySqlTest(ManyToManyTrackingMySqlFixture fixture) 7 | : base(fixture) 8 | { 9 | } 10 | 11 | public class ManyToManyTrackingMySqlFixture : ManyToManyTrackingMySqlFixtureBase 12 | { 13 | protected override string StoreName 14 | => "ManyToManyTrackingMySqlTest"; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MaterializationInterceptionMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; 6 | 7 | public class MaterializationInterceptionMySqlTest : MaterializationInterceptionTestBase<MaterializationInterceptionMySqlTest.MySqlLibraryContext> 8 | { 9 | public class MySqlLibraryContext : LibraryContext 10 | { 11 | public MySqlLibraryContext(DbContextOptions options) 12 | : base(options) 13 | { 14 | } 15 | 16 | protected override void OnModelCreating(ModelBuilder modelBuilder) 17 | { 18 | base.OnModelCreating(modelBuilder); 19 | 20 | modelBuilder.Entity<TestEntity30244>().OwnsMany(e => e.Settings); 21 | 22 | // TODO: https://github.com/npgsql/efcore.pg/issues/2548 23 | // modelBuilder.Entity<TestEntity30244>().OwnsMany(e => e.Settings, b => b.ToJson()); 24 | } 25 | } 26 | 27 | protected override ITestStoreFactory TestStoreFactory 28 | => MySqlTestStoreFactory.Instance; 29 | } 30 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/ModelBuilding101MySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Pomelo.EntityFrameworkCore.MySql.Tests; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; 5 | 6 | public class ModelBuilding101MySqlTest : ModelBuilding101RelationalTestBase 7 | { 8 | protected override DbContextOptionsBuilder ConfigureContext(DbContextOptionsBuilder optionsBuilder) 9 | => optionsBuilder.UseMySql(AppConfig.ServerVersion); 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MonsterFixupChangedChangingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class MonsterFixupChangedChangingMySqlTest : MonsterFixupTestBase<MonsterFixupChangedChangingMySqlTest.MonsterFixupChangedChangingMySqlFixture> 8 | { 9 | public MonsterFixupChangedChangingMySqlTest(MonsterFixupChangedChangingMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class MonsterFixupChangedChangingMySqlFixture : MonsterFixupChangedChangingFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | 18 | protected override void OnModelCreating<TMessage, TProduct, TProductPhoto, TProductReview, TComputerDetail, TDimensions>( 19 | ModelBuilder builder) 20 | { 21 | base.OnModelCreating<TMessage, TProduct, TProductPhoto, TProductReview, TComputerDetail, TDimensions>(builder); 22 | 23 | builder.Entity<TMessage>().HasKey(e => e.MessageId); 24 | builder.Entity<TProductPhoto>().HasKey(e => e.PhotoId); 25 | builder.Entity<TProductReview>().HasKey(e => e.ReviewId); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MusicStoreMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class MusicStoreMySqlTest : MusicStoreTestBase<MusicStoreMySqlTest.MusicStoreMySqlFixture> 8 | { 9 | public MusicStoreMySqlTest(MusicStoreMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class MusicStoreMySqlFixture : MusicStoreFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | 18 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) 19 | { 20 | base.OnModelCreating(modelBuilder, context); 21 | 22 | MySqlTestHelpers.Instance.EnsureSufficientKeySpace(modelBuilder.Model, TestStore); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class MySqlFixture : ServiceProviderFixtureBase 10 | { 11 | public TestSqlLoggerFactory TestSqlLoggerFactory 12 | => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService<ILoggerFactory>(); 13 | 14 | protected override ITestStoreFactory TestStoreFactory 15 | => MySqlTestStoreFactory.Instance; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MySqlNetTopologySuiteApiConsistencyTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class MySqlNetTopologySuiteApiConsistencyTest : ApiConsistencyTestBase<MySqlNetTopologySuiteApiConsistencyTest.MySqlNetTopologySuiteApiConsistencyFixture> 10 | { 11 | public MySqlNetTopologySuiteApiConsistencyTest(MySqlNetTopologySuiteApiConsistencyFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | protected override void AddServices(ServiceCollection serviceCollection) 17 | => serviceCollection.AddEntityFrameworkMySqlNetTopologySuite(); 18 | 19 | protected override Assembly TargetAssembly 20 | => typeof(MySqlNetTopologySuiteServiceCollectionExtensions).Assembly; 21 | 22 | public class MySqlNetTopologySuiteApiConsistencyFixture : ApiConsistencyFixtureBase 23 | { 24 | public override HashSet<Type> FluentApiTypes { get; } = new() 25 | { 26 | typeof(MySqlNetTopologySuiteDbContextOptionsBuilderExtensions), 27 | typeof(MySqlNetTopologySuiteServiceCollectionExtensions) 28 | }; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/MySqlServiceCollectionExtensionsTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 5 | { 6 | public class MySqlServiceCollectionExtensionsTest : RelationalServiceCollectionExtensionsTestBase 7 | { 8 | public MySqlServiceCollectionExtensionsTest() 9 | : base(MySqlTestHelpers.Instance) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/NorthwindQueryTaggingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 4 | using Xunit.Abstractions; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 7 | { 8 | internal class NorthwindQueryTaggingQueryMySqlTest : NorthwindQueryTaggingQueryTestBase<NorthwindQueryMySqlFixture<NoopModelCustomizer>> 9 | { 10 | public NorthwindQueryTaggingQueryMySqlTest( 11 | NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture, 12 | ITestOutputHelper testOutputHelper) 13 | : base(fixture) 14 | { 15 | Fixture.TestSqlLoggerFactory.Clear(); 16 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/NotificationEntitiesMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class NotificationEntitiesMySqlTest : NotificationEntitiesTestBase<NotificationEntitiesMySqlTest.NotificationEntitiesMySqlFixture> 8 | { 9 | public NotificationEntitiesMySqlTest(NotificationEntitiesMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class NotificationEntitiesMySqlFixture : NotificationEntitiesFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/OptimisticConcurrencyMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using Xunit; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class OptimisticConcurrencyMySqlTest : OptimisticConcurrencyRelationalTestBase<F1MySqlFixture, byte[]> 10 | { 11 | public OptimisticConcurrencyMySqlTest(F1MySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) 17 | => facade.UseTransaction(transaction.GetDbTransaction()); 18 | 19 | [ConditionalFact(Skip = "#588")] 20 | public override Task Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values() 21 | { 22 | return base.Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values(); 23 | } 24 | 25 | [ConditionalFact(Skip = "#588")] 26 | public override Task Simple_concurrency_exception_can_be_resolved_with_store_values() 27 | { 28 | return base.Simple_concurrency_exception_can_be_resolved_with_store_values(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/OverzealousInitializationMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class OverzealousInitializationMySqlTest 8 | : OverzealousInitializationTestBase<OverzealousInitializationMySqlTest.OverzealousInitializationMySqlFixture> 9 | { 10 | public OverzealousInitializationMySqlTest(OverzealousInitializationMySqlFixture fixture) 11 | : base(fixture) 12 | { 13 | } 14 | 15 | public class OverzealousInitializationMySqlFixture : OverzealousInitializationFixtureBase 16 | { 17 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/PropertyValuesMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 6 | { 7 | public class PropertyValuesMySqlTest : PropertyValuesTestBase<PropertyValuesMySqlTest.PropertyValuesMySqlFixture> 8 | { 9 | public PropertyValuesMySqlTest(PropertyValuesMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class PropertyValuesMySqlFixture : PropertyValuesFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/AdHocManyToManyQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 6 | 7 | public class AdHocManyToManyQueryMySqlTest : AdHocManyToManyQueryRelationalTestBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/AdHocNavigationsQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 6 | 7 | public class AdHocNavigationsQueryMySqlTest : AdHocNavigationsQueryRelationalTestBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/CaseSensitiveNorthwindQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Infrastructure; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class CaseSensitiveNorthwindQueryMySqlFixture<TModelCustomizer> : NorthwindQueryMySqlFixture<TModelCustomizer> 8 | where TModelCustomizer : ITestModelCustomizer, new() 9 | { 10 | protected override string StoreName => "NorthwindCs"; 11 | protected override ITestStoreFactory TestStoreFactory => MySqlNorthwindTestStoreFactory.InstanceCs; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/CaseSensitiveWithStringComparisonNorthwindQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 5 | 6 | public class CaseSensitiveWithStringComparisonNorthwindQueryMySqlFixture<TModelCustomizer> : CaseSensitiveNorthwindQueryMySqlFixture<TModelCustomizer> 7 | where TModelCustomizer : ITestModelCustomizer, new() 8 | { 9 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 10 | { 11 | var optionsBuilder = base.AddOptions(builder); 12 | new MySqlDbContextOptionsBuilder(optionsBuilder).EnableStringComparisonTranslations(); 13 | return optionsBuilder; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class ComplexNavigationsCollectionsSplitSharedTypeQueryMySqlTest : ComplexNavigationsCollectionsSplitSharedTypeQueryRelationalTestBase<ComplexNavigationsSharedTypeQueryMySqlFixture> 7 | { 8 | public ComplexNavigationsCollectionsSplitSharedTypeQueryMySqlTest( 9 | ComplexNavigationsSharedTypeQueryMySqlFixture fixture, 10 | ITestOutputHelper testOutputHelper) 11 | : base(fixture) 12 | { 13 | Fixture.TestSqlLoggerFactory.Clear(); 14 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class ComplexNavigationsQueryMySqlFixture : ComplexNavigationsQueryRelationalFixtureBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class ComplexNavigationsSharedTypeQueryMySqlFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/CompositeKeysQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class CompositeKeysQueryMySqlFixture : CompositeKeysQueryRelationalFixtureBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/FieldsOnlyLoadMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class FieldsOnlyLoadMySqlTest : FieldsOnlyLoadTestBase<FieldsOnlyLoadMySqlTest.FieldsOnlyLoadMySqlFixture> 8 | { 9 | public FieldsOnlyLoadMySqlTest(FieldsOnlyLoadMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class FieldsOnlyLoadMySqlFixture : FieldsOnlyLoadFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory 17 | => MySqlTestStoreFactory.Instance; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/FromSqlQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Common; 2 | using System.Threading.Tasks; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | using MySqlConnector; 6 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure; 7 | using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; 8 | using Xunit; 9 | 10 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 11 | { 12 | public class FromSqlQueryMySqlTest : FromSqlQueryTestBase<NorthwindQueryMySqlFixture<NoopModelCustomizer>> 13 | { 14 | public FromSqlQueryMySqlTest(NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture) 15 | : base(fixture) 16 | { 17 | } 18 | 19 | [SupportedServerVersionCondition(nameof(ServerVersionSupport.CommonTableExpressions))] 20 | public override Task FromSqlRaw_composed_with_common_table_expression(bool async) 21 | { 22 | return base.FromSqlRaw_composed_with_common_table_expression(async); 23 | } 24 | 25 | protected override DbParameter CreateDbParameter(string name, object value) 26 | => new MySqlParameter 27 | { 28 | ParameterName = name, 29 | Value = value 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/GearsOfWarFromSqlQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 4 | { 5 | public class GearsOfWarFromSqlQueryMySqlTest : GearsOfWarFromSqlQueryTestBase<GearsOfWarQueryMySqlFixture> 6 | { 7 | public GearsOfWarFromSqlQueryMySqlTest(GearsOfWarQueryMySqlFixture fixture) 8 | : base(fixture) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/IncludeMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Diagnostics; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class IncludeMySqlFixture : NorthwindQueryMySqlFixture<NoopModelCustomizer> 8 | { 9 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 10 | => base.AddOptions(builder); 11 | 12 | protected override bool ShouldLogCategory(string logCategory) 13 | => base.ShouldLogCategory(logCategory) || logCategory == DbLoggerCategory.Query.Name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/IncludeOneToOneMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Logging; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 8 | { 9 | public class IncludeOneToOneMySqlTest : IncludeOneToOneTestBase<IncludeOneToOneMySqlTest.OneToOneQueryMySqlFixture> 10 | { 11 | public IncludeOneToOneMySqlTest(OneToOneQueryMySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | public class OneToOneQueryMySqlFixture : OneToOneQueryFixtureBase 17 | { 18 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 19 | 20 | public TestSqlLoggerFactory TestSqlLoggerFactory => 21 | (TestSqlLoggerFactory)ServiceProvider.GetRequiredService<ILoggerFactory>(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/InheritanceRelationshipsQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class InheritanceRelationshipsQueryMySqlFixture : InheritanceRelationshipsQueryRelationalFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/InheritanceRelationshipsQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 4 | { 5 | public class InheritanceRelationshipsQueryMySqlTest : InheritanceRelationshipsQueryRelationalTestBase<InheritanceRelationshipsQueryMySqlFixture> 6 | { 7 | public InheritanceRelationshipsQueryMySqlTest(InheritanceRelationshipsQueryMySqlFixture fixture) 8 | : base(fixture) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ManyToManyNoTrackingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class ManyToManyNoTrackingQueryMySqlTest 7 | : ManyToManyNoTrackingQueryRelationalTestBase<ManyToManyQueryMySqlFixture> 8 | { 9 | public ManyToManyNoTrackingQueryMySqlTest(ManyToManyQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 10 | : base(fixture) 11 | { 12 | Fixture.TestSqlLoggerFactory.Clear(); 13 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ManyToManyQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class ManyToManyQueryMySqlFixture : ManyToManyQueryRelationalFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ManyToManyQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class ManyToManyQueryMySqlTest : ManyToManyQueryRelationalTestBase<ManyToManyQueryMySqlFixture> 7 | { 8 | public ManyToManyQueryMySqlTest(ManyToManyQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 9 | : base(fixture) 10 | { 11 | Fixture.TestSqlLoggerFactory.Clear(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindAsNoTrackingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Xunit.Abstractions; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class NorthwindAsNoTrackingQueryMySqlTest : NorthwindAsNoTrackingQueryTestBase< 8 | NorthwindQueryMySqlFixture<NoopModelCustomizer>> 9 | { 10 | public NorthwindAsNoTrackingQueryMySqlTest( 11 | NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture, 12 | ITestOutputHelper testOutputHelper) 13 | : base(fixture) 14 | { 15 | Fixture.TestSqlLoggerFactory.Clear(); 16 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindAsTrackingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class NorthwindAsTrackingQueryMySqlTest : NorthwindAsTrackingQueryTestBase< 7 | NorthwindQueryMySqlFixture<NoopModelCustomizer>> 8 | { 9 | public NorthwindAsTrackingQueryMySqlTest(NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture) 10 | : base(fixture) 11 | { 12 | Fixture.TestSqlLoggerFactory.Clear(); 13 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindChangeTrackingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestModels.Northwind; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestModels.Northwind; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 8 | { 9 | public class NorthwindChangeTrackingQueryMySqlTest : NorthwindChangeTrackingQueryTestBase< 10 | NorthwindQueryMySqlFixture<NoopModelCustomizer>> 11 | { 12 | public NorthwindChangeTrackingQueryMySqlTest(NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture) 13 | : base(fixture) 14 | { 15 | Fixture.TestSqlLoggerFactory.Clear(); 16 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 17 | } 18 | 19 | protected override NorthwindContext CreateNoTrackingContext() 20 | => new NorthwindMySqlContext( 21 | new DbContextOptionsBuilder(Fixture.CreateOptions()) 22 | .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindCompiledQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Diagnostics; 6 | using Microsoft.EntityFrameworkCore.Query; 7 | using Microsoft.EntityFrameworkCore.TestModels.Northwind; 8 | using Microsoft.EntityFrameworkCore.TestUtilities; 9 | using Xunit; 10 | using Xunit.Abstractions; 11 | 12 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 13 | { 14 | public class NorthwindCompiledQueryMySqlTest : NorthwindCompiledQueryTestBase<NorthwindQueryMySqlFixture<NoopModelCustomizer>> 15 | { 16 | public NorthwindCompiledQueryMySqlTest( 17 | NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture, 18 | ITestOutputHelper testOutputHelper) 19 | : base(fixture) 20 | { 21 | fixture.TestSqlLoggerFactory.Clear(); 22 | //fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 23 | } 24 | 25 | private void AssertSql(params string[] expected) 26 | => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindKeylessEntitiesQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using MySqlConnector; 5 | using Xunit; 6 | using Xunit.Abstractions; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 9 | { 10 | public class NorthwindKeylessEntitiesQueryMySqlTest : NorthwindKeylessEntitiesQueryRelationalTestBase<NorthwindQueryMySqlFixture<NoopModelCustomizer>> 11 | { 12 | public NorthwindKeylessEntitiesQueryMySqlTest(NorthwindQueryMySqlFixture<NoopModelCustomizer> fixture, ITestOutputHelper testOutputHelper) 13 | : base(fixture) 14 | { 15 | Fixture.TestSqlLoggerFactory.Clear(); 16 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 17 | } 18 | 19 | public override async Task KeylessEntity_with_nav_defining_query(bool async) 20 | { 21 | // FromSql mapping. Issue #21627. 22 | await Assert.ThrowsAsync<MySqlException>(() => base.KeylessEntity_with_nav_defining_query(async)); 23 | 24 | AssertSql( 25 | @"SELECT `c`.`CompanyName`, `c`.`OrderCount`, `c`.`SearchTerm` 26 | FROM `CustomerQueryWithQueryFilter` AS `c` 27 | WHERE `c`.`OrderCount` > 0"); 28 | } 29 | 30 | private void AssertSql(params string[] expected) 31 | => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.MySql.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.EntityFrameworkCore; 4 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure; 5 | using Pomelo.EntityFrameworkCore.MySql.Storage; 6 | using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; 7 | using Xunit; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 10 | { 11 | public partial class NorthwindMiscellaneousQueryMySqlTest 12 | { 13 | [ConditionalTheory] 14 | [MemberData(nameof(IsAsyncData))] 15 | [SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.WindowFunctions))] 16 | public virtual Task RowNumberOverPartitionBy_not_supported_throws(bool async) 17 | { 18 | return Assert.ThrowsAsync<InvalidOperationException>(() => base.SelectMany_Joined_Take(async)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NorthwindQueryFiltersQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Xunit.Abstractions; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class NorthwindQueryFiltersQueryMySqlTest : NorthwindQueryFiltersQueryTestBase< 8 | NorthwindQueryMySqlFixture<NorthwindQueryFiltersCustomizer>> 9 | { 10 | public NorthwindQueryFiltersQueryMySqlTest( 11 | NorthwindQueryMySqlFixture<NorthwindQueryFiltersCustomizer> fixture, 12 | ITestOutputHelper testOutputHelper) 13 | : base(fixture) 14 | { 15 | Fixture.TestSqlLoggerFactory.Clear(); 16 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 17 | } 18 | 19 | public override async Task Count_query(bool async) 20 | { 21 | await base.Count_query(async); 22 | 23 | AssertSql( 24 | """ 25 | @__ef_filter__TenantPrefix_0_startswith='B%' (Size = 40) 26 | 27 | SELECT COUNT(*) 28 | FROM `Customers` AS `c` 29 | WHERE `c`.`CompanyName` LIKE @__ef_filter__TenantPrefix_0_startswith 30 | """); 31 | } 32 | 33 | private void AssertSql(params string[] expected) 34 | => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NullKeysMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class NullKeysMySqlTest : NullKeysTestBase<NullKeysMySqlTest.NullKeysMySqlFixture> 8 | { 9 | public NullKeysMySqlTest(NullKeysMySqlFixture fixture) 10 | : base(fixture) 11 | { 12 | } 13 | 14 | public class NullKeysMySqlFixture : NullKeysFixtureBase 15 | { 16 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/NullSemanticsQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class NullSemanticsQueryMySqlFixture : NullSemanticsQueryFixtureBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/OperatorsProceduralMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 6 | 7 | public class OperatorsProceduralMySqlTest : OperatorsProceduralQueryTestBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/OptionalDependentQuerySqlServerFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 6 | 7 | public class OptionalDependentQueryMySqlFixture : OptionalDependentQueryFixtureBase 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/QueryNoClientEvalMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Diagnostics; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class QueryNoClientEvalMySqlFixture : NorthwindQueryMySqlFixture<NoopModelCustomizer> 8 | { 9 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 10 | => base.AddOptions(builder); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/QueryNoClientEvalMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using Xunit; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 7 | { 8 | public class QueryNoClientEvalMySqlTest : QueryNoClientEvalTestBase<QueryNoClientEvalMySqlFixture> 9 | { 10 | public QueryNoClientEvalMySqlTest(QueryNoClientEvalMySqlFixture fixture) 11 | : base(fixture) 12 | { 13 | } 14 | 15 | [ConditionalFact] 16 | public override void Doesnt_throw_when_from_sql_not_composed() 17 | { 18 | using (var context = CreateContext()) 19 | { 20 | var customers 21 | = context.Customers 22 | .FromSqlRaw(@"select * from `Customers`") 23 | .ToList(); 24 | 25 | Assert.Equal(91, customers.Count); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/SpatialQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 7 | 8 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 9 | { 10 | public class SpatialQueryMySqlFixture : SpatialQueryRelationalFixture 11 | { 12 | protected override ITestStoreFactory TestStoreFactory 13 | => MySqlTestStoreFactory.Instance; 14 | 15 | protected override IServiceCollection AddServices(IServiceCollection serviceCollection) 16 | => base.AddServices(serviceCollection) 17 | .AddEntityFrameworkMySqlNetTopologySuite(); 18 | 19 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 20 | { 21 | var optionsBuilder = base.AddOptions(builder); 22 | new MySqlDbContextOptionsBuilder(optionsBuilder) 23 | .UseNetTopologySuite(); 24 | 25 | return optionsBuilder; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPCFiltersInheritanceQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 2 | 3 | public class TPCFiltersInheritanceQueryMySqlFixture : TPCInheritanceQueryMySqlFixture 4 | { 5 | public override bool EnableFilters 6 | => true; 7 | } 8 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPCInheritanceQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using Xunit.Abstractions; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 8 | 9 | public class TPCInheritanceQueryMySqlTest : TPCInheritanceQueryTestBase<TPCInheritanceQueryMySqlFixture> 10 | { 11 | public TPCInheritanceQueryMySqlTest( 12 | TPCInheritanceQueryMySqlFixture fixture, 13 | ITestOutputHelper testOutputHelper) 14 | : base(fixture, testOutputHelper) 15 | { 16 | Fixture.TestSqlLoggerFactory.Clear(); 17 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 18 | } 19 | 20 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) 21 | => facade.UseTransaction(transaction.GetDbTransaction()); 22 | } 23 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPHInheritanceQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 6 | 7 | public class TPHInheritanceQueryMySqlFixture : TPHInheritanceQueryFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPHInheritanceQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 5 | 6 | public class TPHInheritanceQueryMySqlTest : TPHInheritanceQueryTestBase<TPHInheritanceQueryMySqlFixture> 7 | { 8 | public TPHInheritanceQueryMySqlTest(TPHInheritanceQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 9 | : base(fixture, testOutputHelper) 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTFiltersInheritanceQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 2 | { 3 | public class TPTFiltersInheritanceQueryMySqlFixture : TPTInheritanceQueryMySqlFixture 4 | { 5 | public override bool EnableFilters 6 | => true; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTFiltersInheritanceQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class TPTFiltersInheritanceQueryMySqlTest : TPTFiltersInheritanceQueryTestBase<TPTFiltersInheritanceQueryMySqlFixture> 7 | { 8 | public TPTFiltersInheritanceQueryMySqlTest(TPTFiltersInheritanceQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 9 | : base(fixture) 10 | { 11 | Fixture.TestSqlLoggerFactory.Clear(); 12 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTInheritanceQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class TPTInheritanceQueryMySqlFixture : TPTInheritanceQueryFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTInheritanceQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class TPTInheritanceQueryMySqlTest : TPTInheritanceQueryTestBase<TPTInheritanceQueryMySqlFixture> 7 | { 8 | public TPTInheritanceQueryMySqlTest( 9 | TPTInheritanceQueryMySqlFixture fixture, 10 | ITestOutputHelper testOutputHelper) 11 | : base(fixture, testOutputHelper) 12 | { 13 | Fixture.TestSqlLoggerFactory.Clear(); 14 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTManyToManyNoTrackingQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class TPTManyToManyNoTrackingQueryMySqlTest : TPTManyToManyNoTrackingQueryRelationalTestBase<TPTManyToManyQueryMySqlFixture> 7 | { 8 | public TPTManyToManyNoTrackingQueryMySqlTest(TPTManyToManyQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 9 | : base(fixture) 10 | { 11 | Fixture.TestSqlLoggerFactory.Clear(); 12 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTManyToManyQueryMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 6 | { 7 | public class TPTManyToManyQueryMySqlFixture : TPTManyToManyQueryRelationalFixture 8 | { 9 | protected override ITestStoreFactory TestStoreFactory 10 | => MySqlTestStoreFactory.Instance; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTManyToManyQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 5 | { 6 | public class TPTManyToManyQueryMySqlTest : TPTManyToManyQueryRelationalTestBase<TPTManyToManyQueryMySqlFixture> 7 | { 8 | public TPTManyToManyQueryMySqlTest(TPTManyToManyQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) 9 | : base(fixture) 10 | { 11 | Fixture.TestSqlLoggerFactory.Clear(); 12 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/TPTRelationshipsQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | using Xunit.Abstractions; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 7 | { 8 | public class TPTRelationshipsQueryMySqlTest 9 | : TPTRelationshipsQueryTestBase<TPTRelationshipsQueryMySqlTest.TPTRelationshipsQueryMySqlFixture> 10 | { 11 | public TPTRelationshipsQueryMySqlTest( 12 | TPTRelationshipsQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) 13 | => fixture.TestSqlLoggerFactory.Clear(); 14 | 15 | public class TPTRelationshipsQueryMySqlFixture : TPTRelationshipsQueryRelationalFixture 16 | { 17 | protected override ITestStoreFactory TestStoreFactory 18 | => MySqlTestStoreFactory.Instance; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/ToSqlQueryMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 5 | using Xunit; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; 8 | 9 | public class ToSqlQueryMySqlTest : ToSqlQueryTestBase 10 | { 11 | protected override ITestStoreFactory TestStoreFactory 12 | => MySqlTestStoreFactory.Instance; 13 | 14 | [ConditionalFact] 15 | public virtual void Check_all_tests_overridden() 16 | => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); 17 | 18 | public override async Task Entity_type_with_navigation_mapped_to_SqlQuery(bool async) 19 | { 20 | await base.Entity_type_with_navigation_mapped_to_SqlQuery(async); 21 | 22 | AssertSql( 23 | """ 24 | SELECT `a`.`Id`, `a`.`Name`, `a`.`PostStatAuthorId`, `m`.`Count` AS `PostCount` 25 | FROM `Authors` AS `a` 26 | LEFT JOIN ( 27 | SELECT * FROM PostStats 28 | ) AS `m` ON `a`.`PostStatAuthorId` = `m`.`AuthorId` 29 | """); 30 | } 31 | 32 | private void AssertSql(params string[] expected) 33 | => TestSqlLoggerFactory.AssertBaseline(expected); 34 | } 35 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Query/WarningsMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Query; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query 4 | { 5 | public class WarningsMySqlTest : WarningsTestBase<QueryNoClientEvalMySqlFixture> 6 | { 7 | public WarningsMySqlTest(QueryNoClientEvalMySqlFixture fixture) 8 | : base(fixture) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/README.md: -------------------------------------------------------------------------------- 1 | Functional Tests 2 | ================================ 3 | 4 | **Configuring the Database** 5 | 6 | Configure your MySQL database by opening the `config.json.example` file, specifying the connection string and saving the changed file as `config.json`. 7 | 8 | **Running Functional Tests** 9 | 10 | 1. Ensure that you configured the database (see previous paragraph). 11 | 2. Run `dotnet test`. This will execute all tests in the project. -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/BigModel/DataUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DataUnsafeAccessors 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Blob>k__BackingField")] 14 | public static extern ref byte[] Blob(CompiledModelTestBase.Data @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/BigModel/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System.Runtime.CompilerServices; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | 5 | #pragma warning disable 219, 612, 618 6 | #nullable disable 7 | 8 | namespace TestNamespace 9 | { 10 | public static class DependentBaseUnsafeAccessors<TKey> 11 | { 12 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Id>k__BackingField")] 13 | public static extern ref TKey Id(CompiledModelTestBase.DependentBase<TKey> @this); 14 | 15 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Principal>k__BackingField")] 16 | public static extern ref CompiledModelTestBase.PrincipalDerived<CompiledModelTestBase.DependentBase<TKey>> Principal(CompiledModelTestBase.DependentBase<TKey> @this); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/BigModel/DependentDerivedUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DependentDerivedUnsafeAccessors<TKey> 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Data>k__BackingField")] 14 | public static extern ref string Data(CompiledModelTestBase.DependentDerived<TKey> @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/BigModel/PrincipalDerivedUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class PrincipalDerivedUnsafeAccessors<TDependent> 12 | where TDependent : class 13 | { 14 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Dependent>k__BackingField")] 15 | public static extern ref TDependent Dependent(CompiledModelTestBase.PrincipalDerived<TDependent> @this); 16 | 17 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "ManyOwned")] 18 | public static extern ref ICollection<CompiledModelTestBase.OwnedType> ManyOwned(CompiledModelTestBase.PrincipalDerived<TDependent> @this); 19 | 20 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Principals>k__BackingField")] 21 | public static extern ref ICollection<CompiledModelTestBase.PrincipalBase> Principals(CompiledModelTestBase.PrincipalDerived<TDependent> @this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/CheckConstraints/DataUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DataUnsafeAccessors 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Blob>k__BackingField")] 14 | public static extern ref byte[] Blob(CompiledModelTestBase.Data @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/CheckConstraints/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Custom_function_parameter_type_mapping/FunctionParameterTypeMappingContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(CompiledModelRelationalTestBase.FunctionParameterTypeMappingContext), typeof(FunctionParameterTypeMappingContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Custom_function_type_mapping/FunctionTypeMappingContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(CompiledModelRelationalTestBase.FunctionTypeMappingContext), typeof(FunctionTypeMappingContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/DbFunctions/DataUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DataUnsafeAccessors 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Blob>k__BackingField")] 14 | public static extern ref byte[] Blob(CompiledModelTestBase.Data @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/DbFunctions/DbFunctionContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(CompiledModelRelationalTestBase.DbFunctionContext), typeof(DbFunctionContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Dynamic_schema/DataUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DataUnsafeAccessors 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Blob>k__BackingField")] 14 | public static extern ref byte[] Blob(CompiledModelTestBase.Data @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Dynamic_schema/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Sequences/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/SimpleModel/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/SimpleModel/DependentBaseUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System.Runtime.CompilerServices; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | 5 | #pragma warning disable 219, 612, 618 6 | #nullable disable 7 | 8 | namespace TestNamespace 9 | { 10 | public static class DependentBaseUnsafeAccessors<TKey> 11 | { 12 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Id>k__BackingField")] 13 | public static extern ref TKey Id(CompiledModelTestBase.DependentBase<TKey> @this); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/SimpleModel/DependentDerivedUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DependentDerivedUnsafeAccessors<TKey> 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Data>k__BackingField")] 14 | public static extern ref string Data(CompiledModelTestBase.DependentDerived<TKey> @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Tpc_Sprocs/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Tpc_Sprocs/DependentBaseUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System.Runtime.CompilerServices; 3 | using Microsoft.EntityFrameworkCore.Scaffolding; 4 | 5 | #pragma warning disable 219, 612, 618 6 | #nullable disable 7 | 8 | namespace TestNamespace 9 | { 10 | public static class DependentBaseUnsafeAccessors<TKey> 11 | { 12 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Id>k__BackingField")] 13 | public static extern ref TKey Id(CompiledModelTestBase.DependentBase<TKey> @this); 14 | 15 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Principal>k__BackingField")] 16 | public static extern ref CompiledModelTestBase.PrincipalDerived<CompiledModelTestBase.DependentBase<TKey>> Principal(CompiledModelTestBase.DependentBase<TKey> @this); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Tpc_Sprocs/PrincipalDerivedUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class PrincipalDerivedUnsafeAccessors<TDependent> 12 | where TDependent : class 13 | { 14 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Dependent>k__BackingField")] 15 | public static extern ref TDependent Dependent(CompiledModelTestBase.PrincipalDerived<TDependent> @this); 16 | 17 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Principals>k__BackingField")] 18 | public static extern ref ICollection<CompiledModelTestBase.PrincipalBase> Principals(CompiledModelTestBase.PrincipalDerived<TDependent> @this); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Triggers/DataUnsafeAccessors.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using Microsoft.EntityFrameworkCore.Scaffolding; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | namespace TestNamespace 10 | { 11 | public static class DataUnsafeAccessors 12 | { 13 | [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Blob>k__BackingField")] 14 | public static extern ref byte[] Blob(CompiledModelTestBase.Data @this); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/Scaffolding/Baselines/Triggers/DbContextAssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // <auto-generated /> 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using TestNamespace; 5 | 6 | #pragma warning disable 219, 612, 618 7 | #nullable disable 8 | 9 | [assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))] 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/SeedingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.TestUtilities; 3 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 4 | using Pomelo.EntityFrameworkCore.MySql.Tests; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 7 | { 8 | public class SeedingMySqlTest : SeedingTestBase 9 | { 10 | protected override TestStore TestStore => MySqlTestStore.Create("SeedingTest"); 11 | 12 | protected override SeedingContext CreateContextWithEmptyDatabase(string testId) 13 | => new SeedingMySqlContext(testId); 14 | 15 | protected class SeedingMySqlContext : SeedingContext 16 | { 17 | public SeedingMySqlContext(string testId) 18 | : base(testId) 19 | { 20 | } 21 | 22 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 23 | => optionsBuilder.UseMySql(MySqlTestStore.CreateConnectionString(quot;Seeds{TestId}"), AppConfig.ServerVersion); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/SerializationMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 4 | { 5 | public class SerializationMySqlTest : SerializationTestBase<F1MySqlFixture> 6 | { 7 | public SerializationMySqlTest(F1MySqlFixture fixture) 8 | : base(fixture) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/SpatialMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class SpatialMySqlFixture : SpatialFixtureBase 10 | { 11 | protected override ITestStoreFactory TestStoreFactory 12 | => MySqlTestStoreFactory.Instance; 13 | 14 | protected override IServiceCollection AddServices(IServiceCollection serviceCollection) 15 | => base.AddServices(serviceCollection) 16 | .AddEntityFrameworkMySqlNetTopologySuite(); 17 | 18 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) 19 | { 20 | var optionsBuilder = base.AddOptions(builder); 21 | new MySqlDbContextOptionsBuilder(optionsBuilder) 22 | .UseNetTopologySuite(); 23 | 24 | return optionsBuilder; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TPTTableSplittingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestUtilities; 4 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 5 | using Xunit.Abstractions; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class TPTTableSplittingMySqlTest : TPTTableSplittingTestBase 10 | { 11 | public TPTTableSplittingMySqlTest(ITestOutputHelper testOutputHelper) 12 | : base(testOutputHelper) 13 | { 14 | } 15 | 16 | public override Task Can_insert_dependent_with_just_one_parent() 17 | { 18 | // This scenario is not valid for TPT 19 | return Task.CompletedTask; 20 | } 21 | 22 | protected override ITestStoreFactory TestStoreFactory 23 | => MySqlTestStoreFactory.Instance; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TableSplittingMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.TestModels.TransportationModel; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure; 6 | using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; 7 | using Xunit.Abstractions; 8 | 9 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 10 | { 11 | [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] 12 | public class TableSplittingMySqlTest : TableSplittingTestBase 13 | { 14 | public TableSplittingMySqlTest(ITestOutputHelper testOutputHelper) 15 | : base(testOutputHelper) 16 | { 17 | } 18 | 19 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 20 | 21 | protected override void OnModelCreating(ModelBuilder modelBuilder) 22 | { 23 | base.OnModelCreating(modelBuilder); 24 | 25 | modelBuilder.Entity<Engine>().ToTable("Vehicles") 26 | .Property(e => e.Computed).HasComputedColumnSql("1", stored: true); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using JetBrains.Annotations; 3 | using Microsoft.EntityFrameworkCore.Storage; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.DebugServices; 6 | 7 | public class DebugRelationalCommand : RelationalCommand 8 | { 9 | public DebugRelationalCommand( 10 | [NotNull] RelationalCommandBuilderDependencies dependencies, 11 | [NotNull] string commandText, 12 | [NotNull] IReadOnlyList<IRelationalParameter> parameters) 13 | : base(dependencies, commandText, parameters) 14 | { 15 | } 16 | 17 | protected override RelationalDataReader CreateRelationalDataReader() 18 | => new DebugRelationalDataReader(); 19 | } 20 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilder.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Annotations; 2 | using Microsoft.EntityFrameworkCore.Storage; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.DebugServices; 5 | 6 | public class DebugRelationalCommandBuilder : RelationalCommandBuilder 7 | { 8 | public DebugRelationalCommandBuilder([NotNull] RelationalCommandBuilderDependencies dependencies) 9 | : base(dependencies) 10 | { 11 | } 12 | 13 | public override IRelationalCommand Build() 14 | => new DebugRelationalCommand(Dependencies, base.Build().CommandText, Parameters); 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilderFactory.cs: -------------------------------------------------------------------------------- 1 | using JetBrains.Annotations; 2 | using Microsoft.EntityFrameworkCore.Storage; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.DebugServices; 5 | 6 | public class DebugRelationalCommandBuilderFactory : RelationalCommandBuilderFactory 7 | { 8 | public DebugRelationalCommandBuilderFactory([NotNull] RelationalCommandBuilderDependencies dependencies) 9 | : base(dependencies) 10 | { 11 | } 12 | 13 | public override IRelationalCommandBuilder Create() 14 | => new DebugRelationalCommandBuilder(Dependencies); 15 | } 16 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlConnectionStringTestStoreFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.TestUtilities; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities 5 | { 6 | public class MySqlConnectionStringTestStoreFactory : RelationalTestStoreFactory 7 | { 8 | public static MySqlConnectionStringTestStoreFactory Instance { get; } = new MySqlConnectionStringTestStoreFactory(); 9 | 10 | protected MySqlConnectionStringTestStoreFactory() 11 | { 12 | } 13 | 14 | public override TestStore Create(string storeName) 15 | => MySqlTestStore.Create(storeName, useConnectionString: true); 16 | 17 | public override TestStore GetOrCreate(string storeName) 18 | => MySqlTestStore.GetOrCreate(storeName, useConnectionString: true); 19 | 20 | public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection) 21 | => serviceCollection.AddEntityFrameworkMySql(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlDatabaseFacadeTestExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using Microsoft.EntityFrameworkCore.Storage; 4 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities 7 | { 8 | public static class MySqlDatabaseFacadeTestExtensions 9 | { 10 | public static void EnsureClean(this DatabaseFacade databaseFacade) 11 | => new MySqlDatabaseCleaner( 12 | databaseFacade.GetService<IMySqlOptions>(), 13 | databaseFacade.GetService<IRelationalTypeMappingSource>()) 14 | .Clean(databaseFacade); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlDbContextOptionsBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities 6 | { 7 | public static class MySqlDbContextOptionsBuilderExtensions 8 | { 9 | public static MySqlDbContextOptionsBuilder ApplyConfiguration(this MySqlDbContextOptionsBuilder optionsBuilder) 10 | { 11 | var maxBatch = TestEnvironment.GetInt(nameof(MySqlDbContextOptionsBuilder.MaxBatchSize)); 12 | if (maxBatch.HasValue) 13 | { 14 | optionsBuilder.MaxBatchSize(maxBatch.Value); 15 | } 16 | 17 | optionsBuilder.ExecutionStrategy(d => new TestMySqlRetryingExecutionStrategy(d)); 18 | 19 | optionsBuilder.CommandTimeout(MySqlTestStore.DefaultCommandTimeout); 20 | 21 | return optionsBuilder; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlNorthwindTestStoreFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.TestUtilities; 2 | using Pomelo.EntityFrameworkCore.MySql.Tests; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities 5 | { 6 | public class MySqlNorthwindTestStoreFactory : MySqlTestStoreFactory 7 | { 8 | public const string DefaultNamePrefix = "Northwind"; 9 | 10 | public static new MySqlNorthwindTestStoreFactory Instance => InstanceCi; 11 | public static new MySqlNorthwindTestStoreFactory InstanceCi { get; } = new MySqlNorthwindTestStoreFactory(databaseCollation: AppConfig.ServerVersion.DefaultUtf8CiCollation); 12 | public static new MySqlNorthwindTestStoreFactory InstanceCs { get; } = new MySqlNorthwindTestStoreFactory(databaseCollation: AppConfig.ServerVersion.DefaultUtf8CsCollation); 13 | public static new MySqlNorthwindTestStoreFactory NoBackslashEscapesInstance { get; } = new MySqlNorthwindTestStoreFactory(true); 14 | 15 | protected MySqlNorthwindTestStoreFactory(bool noBackslashEscapes = false, string databaseCollation = null) 16 | : base(noBackslashEscapes, databaseCollation) 17 | { 18 | } 19 | 20 | public override TestStore GetOrCreate(string storeName) 21 | => MySqlTestStore.GetOrCreate(storeName ?? quot;{DefaultNamePrefix}__{DatabaseCollation}", "Northwind.sql", noBackslashEscapes: NoBackslashEscapes, databaseCollation: DatabaseCollation); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/TestEnvironment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Configuration; 3 | using MySqlConnector; 4 | using Pomelo.EntityFrameworkCore.MySql.Tests; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities 7 | { 8 | public static class TestEnvironment 9 | { 10 | public static IConfiguration Config => AppConfig.Config; 11 | public static string DefaultConnection => AppConfig.ConnectionString; 12 | 13 | public static bool IsCI { get; } = Environment.GetEnvironmentVariable("PIPELINE_WORKSPACE") != null 14 | || Environment.GetEnvironmentVariable("TEAMCITY_VERSION") != null; 15 | 16 | static TestEnvironment() 17 | { 18 | System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); 19 | } 20 | 21 | public static string GetDefaultConnectionString(string databaseName) 22 | => new MySqlConnectionStringBuilder(DefaultConnection) 23 | { 24 | Database = databaseName 25 | }.ConnectionString; 26 | 27 | public static int? GetInt(string key) 28 | => int.TryParse(Config[key], out var value) ? value : (int?)null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/IMySqlTestClassOrderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit; 5 | 6 | public interface IMySqlTestClassOrderer 7 | { 8 | IEnumerable<ITestClass> OrderTestClasses(IEnumerable<ITestClass> testClasses); 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/MySqlConditionalFactDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; 2 | using Xunit.Abstractions; 3 | using Xunit.Sdk; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit 6 | { 7 | public class MySqlConditionalFactDiscoverer : ConditionalFactDiscoverer 8 | { 9 | public MySqlConditionalFactDiscoverer(IMessageSink messageSink) 10 | : base(messageSink) 11 | { 12 | } 13 | 14 | protected override IXunitTestCase CreateTestCase( 15 | ITestFrameworkDiscoveryOptions discoveryOptions, 16 | ITestMethod testMethod, 17 | IAttributeInfo factAttribute) 18 | => new MySqlConditionalFactTestCase( 19 | DiagnosticMessageSink, 20 | discoveryOptions.MethodDisplayOrDefault(), 21 | discoveryOptions.MethodDisplayOptionsOrDefault(), 22 | testMethod); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/MySqlTestCollectionOrderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Xunit; 5 | using Xunit.Abstractions; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit 8 | { 9 | public class MySqlTestCollectionOrderer : ITestCollectionOrderer 10 | { 11 | public IEnumerable<ITestCollection> OrderTestCollections(IEnumerable<ITestCollection> testCollections) 12 | => testCollections 13 | .OrderBy(c => c.DisplayName, StringComparer.OrdinalIgnoreCase) 14 | .ThenBy(c => c.DisplayName, StringComparer.Ordinal) 15 | .ThenBy(c => c.UniqueID); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/MySqlXunitTestAssemblyRunner.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Xunit.Abstractions; 5 | using Xunit.Sdk; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit; 8 | 9 | public class MySqlXunitTestAssemblyRunner : XunitTestAssemblyRunner 10 | { 11 | public MySqlXunitTestAssemblyRunner( 12 | ITestAssembly testAssembly, 13 | IEnumerable<IXunitTestCase> testCases, 14 | IMessageSink diagnosticMessageSink, 15 | IMessageSink executionMessageSink, 16 | ITestFrameworkExecutionOptions executionOptions) 17 | : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions) 18 | { 19 | } 20 | 21 | protected override Task<RunSummary> RunTestCollectionAsync( 22 | IMessageBus messageBus, 23 | ITestCollection testCollection, 24 | IEnumerable<IXunitTestCase> testCases, 25 | CancellationTokenSource cancellationTokenSource) 26 | => new MySqlXunitTestCollectionRunner( 27 | testCollection, 28 | testCases, 29 | DiagnosticMessageSink, 30 | messageBus, 31 | TestCaseOrderer, 32 | new ExceptionAggregator(Aggregator), 33 | cancellationTokenSource).RunAsync(); 34 | } 35 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/MySqlXunitTestFramework.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Xunit.Abstractions; 4 | using Xunit.Sdk; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit 7 | { 8 | public class MySqlXunitTestFramework : XunitTestFramework 9 | { 10 | public MySqlXunitTestFramework(IMessageSink messageSink) : base(messageSink) 11 | { 12 | } 13 | 14 | protected override ITestFrameworkDiscoverer CreateDiscoverer(IAssemblyInfo assemblyInfo) 15 | => new MySqlXunitTestFrameworkDiscoverer(assemblyInfo, SourceInformationProvider, DiagnosticMessageSink); 16 | 17 | protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName) 18 | => new MySqlXunitTestFrameworkExecutor(assemblyName, SourceInformationProvider, DiagnosticMessageSink); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/TestUtilities/Xunit/MySqlXunitTestFrameworkExecutor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using Xunit.Abstractions; 4 | using Xunit.Sdk; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit; 7 | 8 | public class MySqlXunitTestFrameworkExecutor : XunitTestFrameworkExecutor 9 | { 10 | public MySqlXunitTestFrameworkExecutor( 11 | AssemblyName assemblyName, 12 | ISourceInformationProvider sourceInformationProvider, 13 | IMessageSink diagnosticMessageSink) 14 | : base(assemblyName, sourceInformationProvider, diagnosticMessageSink) 15 | { 16 | } 17 | 18 | protected override async void RunTestCases( 19 | IEnumerable<IXunitTestCase> testCases, 20 | IMessageSink executionMessageSink, 21 | ITestFrameworkExecutionOptions executionOptions) 22 | { 23 | using var assemblyRunner = new MySqlXunitTestAssemblyRunner( 24 | TestAssembly, 25 | testCases, 26 | DiagnosticMessageSink, 27 | executionMessageSink, 28 | executionOptions); 29 | await assemblyRunner.RunAsync(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/UpdatesMySqlFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.TestUtilities; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/WithConstructorsMySqlTest.cs: -------------------------------------------------------------------------------- 1 | using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using Microsoft.EntityFrameworkCore.TestUtilities; 6 | 7 | namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests 8 | { 9 | public class WithConstructorsMySqlTest : WithConstructorsTestBase<WithConstructorsMySqlTest.WithConstructorsMySqlFixture> 10 | { 11 | public WithConstructorsMySqlTest(WithConstructorsMySqlFixture fixture) 12 | : base(fixture) 13 | { 14 | } 15 | 16 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) 17 | => facade.UseTransaction(transaction.GetDbTransaction()); 18 | 19 | public class WithConstructorsMySqlFixture : WithConstructorsFixtureBase 20 | { 21 | protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; 22 | 23 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) 24 | { 25 | base.OnModelCreating(modelBuilder, context); 26 | modelBuilder.Entity<BlogQuery>() 27 | .HasNoKey() 28 | .ToSqlQuery("select * from `Blog`"); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/EFCore.MySql.FunctionalTests/config.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "Data": { 3 | "ConnectionString": "server=127.0.0.1;user id=root;password=Password12!;port=3306;sslmode=none;maxpoolsize=200;", 4 | "ServerVersion": "auto", 5 | "CommandTimeout": "600" 6 | } 7 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/.gitignore: -------------------------------------------------------------------------------- 1 | /config.json 2 | /Migrations/*.cs 3 | /scripts/vegeta/results.bin 4 | /.vscode 5 | /Scaffold 6 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/ConnectionStringCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Pomelo.EntityFrameworkCore.MySql.Tests; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 5 | { 6 | public class ConnectionStringCommand : IConnectionStringCommand 7 | { 8 | public void Run() 9 | { 10 | Console.Write(AppConfig.ConnectionString); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/ICommandRunner.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 2 | { 3 | 4 | public interface ICommandRunner 5 | { 6 | int Run(string[] args); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/IConnectionStringCommand.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 2 | { 3 | 4 | public interface IConnectionStringCommand 5 | { 6 | void Run(); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/ITestMigrateCommand.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 2 | { 3 | 4 | public interface ITestMigrateCommand 5 | { 6 | void Run(); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/ITestPerformanceCommand.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 2 | { 3 | 4 | public interface ITestPerformanceCommand 5 | { 6 | void Run(int iterations, int concurrency, int ops); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/ITestPerformanceRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands 5 | { 6 | 7 | public interface ITestPerformanceRunner 8 | { 9 | Task ConnectionTask(Func<AppDb, Task> cb, int ops); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Commands/TestPerformanceRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands{ 5 | 6 | public class TestPerformanceRunner : ITestPerformanceRunner 7 | { 8 | 9 | private AppDb _db; 10 | 11 | public TestPerformanceRunner(AppDb db) 12 | { 13 | _db = db; 14 | } 15 | 16 | public async Task ConnectionTask(Func<AppDb, Task> cb, int ops) 17 | { 18 | for (var op = 0; op < ops; op++) 19 | { 20 | await cb(_db); 21 | } 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Migrations/readme.txt: -------------------------------------------------------------------------------- 1 | run scripts/rebuild.ps1 or scripts/rebuild.sh to instantiate the migrations and database 2 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Models/Batch.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models 5 | { 6 | public class Product 7 | { 8 | public Product() 9 | { 10 | ProductCategories = new List<ProductCategory>(); 11 | } 12 | 13 | public int ProductId { get; set; } 14 | public string Name { get; set; } 15 | public int? ParentProductId { get; set; } 16 | 17 | public List<ProductCategory> ProductCategories { get; set; } 18 | 19 | [ForeignKey(nameof(ParentProductId))] 20 | public Product ParentProduct { get; set; } 21 | [InverseProperty(nameof(ParentProduct))] 22 | public List<Product> ChildProducts { get; set; } 23 | } 24 | 25 | public class ProductCategory 26 | { 27 | public int ProductId { get; set; } 28 | public Product Product { get; set; } 29 | public int CategoryId { get; set; } 30 | public Category Category { get; set; } 31 | } 32 | 33 | public class Category 34 | { 35 | public Category() 36 | { 37 | ProductCategories = new List<ProductCategory>(); 38 | } 39 | 40 | public int CategoryId { get; set; } 41 | public string Name { get; set; } 42 | 43 | public List<ProductCategory> ProductCategories { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Models/Blog.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models 4 | { 5 | public class Blog 6 | { 7 | public int Id { get; set; } 8 | public string Title { get; set; } 9 | 10 | public List<BlogPost> Posts { get; set; } 11 | } 12 | 13 | public class BlogPost 14 | { 15 | public int Id { get; set; } 16 | public string Title { get; set; } 17 | public string Content { get; set; } 18 | 19 | public int BlogId { get; set; } 20 | public Blog Blog { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Models/Identity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | 3 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models 4 | { 5 | public class AppIdentityUser : IdentityUser 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Models/Sequence.cs: -------------------------------------------------------------------------------- 1 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models 2 | { 3 | 4 | public class Sequence 5 | { 6 | public int Id { get; set; } 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:3723/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "EFCore.MySql.IntegrationTests": { 19 | "commandName": "Project", 20 | "commandLineArgs": "testMigrate", /* debug */ 21 | "launchBrowser": true, 22 | "environmentVariables": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "applicationUrl": "http://localhost:3724/" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/Tests/Models/SequenceTest.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models; 3 | using Xunit; 4 | 5 | namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Tests.Models 6 | { 7 | public class SequenceTest 8 | { 9 | [Fact] 10 | public async Task SequenceIncrement() 11 | { 12 | var sequence1 = new Sequence(); 13 | var sequence2 = new Sequence(); 14 | using (var scope = new AppDbScope()) 15 | { 16 | scope.AppDb.Sequence.AddRange(new []{sequence1, sequence2}); 17 | await scope.AppDb.SaveChangesAsync(); 18 | } 19 | Assert.Equal(sequence1.Id + 1, sequence2.Id); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/appsettings.ci.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "None" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Error", 6 | "System": "Error", 7 | "Microsoft": "None" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/config.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "Data": { 3 | "ConnectionString": "server=127.0.0.1;user id=root;password=Password12!;port=3306;sslmode=none;database=pomelo_test;", 4 | "ServerVersion": "auto", 5 | "CommandTimeout": "600" 6 | } 7 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/legacy.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | 3 | Push-Location (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "../") 4 | 5 | try 6 | { 7 | dotnet tool restore; 8 | 9 | $legacyVersions = Get-ChildItem 'LegacyMigrations' -Directory | % { $_.Name } 10 | 11 | foreach ($legacyVersion in $legacyVersions) 12 | { 13 | Remove-Item (Join-Path 'Migrations' '*.cs') 14 | dotnet ef database drop -f 15 | 16 | Copy-Item (Join-Path 'LegacyMigrations' $legacyVersion '*.csbak') 'Migrations' 17 | Get-ChildItem (Join-Path 'Migrations' '*.csbak') | % { Rename-Item -Path $_.FullName -NewName ([System.IO.Path]::ChangeExtension($_.Name, ".cs")) } 18 | 19 | dotnet ef migrations add Current --verbose 20 | dotnet ef database update --verbose 21 | dotnet test 22 | break; 23 | } 24 | } 25 | finally 26 | { 27 | # Remove-Item (Join-Path 'Migrations' '*.cs') 28 | Pop-Location 29 | } 30 | -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/rebuild.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | 3 | function Insert-Content($file) 4 | { 5 | BEGIN { 6 | $content = Get-Content $file 7 | } 8 | PROCESS { 9 | $_ | Set-Content $file 10 | } 11 | END { 12 | $content | Add-Content $file 13 | } 14 | } 15 | 16 | Push-Location (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "../") 17 | 18 | try 19 | { 20 | dotnet tool restore; 21 | 22 | Remove-Item (Join-Path "Migrations" "*.cs") 23 | 24 | dotnet ef database drop -f 25 | dotnet ef migrations add Initial 26 | 27 | # add using System.Collections.Generic to the migration files 28 | Get-ChildItem (Join-Path "Migrations" "*.cs") | ForEach-Object { 29 | if (!( select-string -pattern "using System.Collections.Generic;" -path $_.FullName)) 30 | { 31 | $_.FullName 32 | "using System.Collections.Generic;" | Insert-Content $_.FullName 33 | } 34 | } 35 | 36 | dotnet ef database update 37 | } 38 | finally 39 | { 40 | Pop-Location 41 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/scaffold.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | 3 | Push-Location (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "../") 4 | 5 | try 6 | { 7 | dotnet tool restore; 8 | 9 | $targetDirectoryName = "Scaffold" 10 | $tables = 'DataTypesSimple', 'DataTypesVariable' 11 | 12 | Remove-Item -Recurse -Force $targetDirectoryName -ErrorAction Ignore 13 | mkdir $targetDirectoryName 14 | 15 | $connectionString = (Select-String config.json -Pattern '(?<="ConnectionString":\s*")(.*?)(?=")').Matches.Value 16 | $arguments = "ef", "dbcontext", "scaffold", $connectionString, "Pomelo.EntityFrameworkCore.MySql", "--output-dir", $targetDirectoryName 17 | 18 | foreach ($table in $tables) 19 | { 20 | $arguments += "--table", $table 21 | } 22 | 23 | & dotnet $arguments 24 | 25 | foreach ($table in $tables) 26 | { 27 | $file = Join-Path $targetDirectoryName, $table + '.cs' 28 | 29 | if (!(Test-Path $file -PathType Leaf)) 30 | { 31 | throw "Failed to scaffold file: $file" 32 | } 33 | } 34 | } 35 | finally 36 | { 37 | Remove-Item -Recurse -Force $targetDirectoryName -ErrorAction Ignore 38 | Pop-Location 39 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/stress.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env powershell 2 | 3 | Push-Location (Join-Path (Split-Path $MyInvocation.MyCommand.Path) vegeta) 4 | 5 | try 6 | { 7 | $RATE = "50" 8 | $DURATION = "5s" 9 | $TARGETS = "async" 10 | if ($args.count -ge 1) 11 | { 12 | $RATE = $args[0] 13 | } 14 | if ($args.count -ge 2) 15 | { 16 | $DURATION = $args[1] 17 | } 18 | if ($args.count -ge 3) 19 | { 20 | $TARGETS = $args[2] 21 | } 22 | $TARGETS = "targets-" + $TARGETS + ".txt" 23 | 24 | Write-Host "Rate = $RATE RPS" 25 | Write-Host "Duration = $DURATION" 26 | Write-Host "Targets = $TARGETS" 27 | 28 | # warm up the JIT Compiler 29 | vegeta attack -targets="$TARGETS" -rate=10 -duration=1s | Out-Null 30 | # run the actual test 31 | # need to save to results.bin since piping will encode data 32 | vegeta attack -targets="$TARGETS" -rate="$RATE" -duration="$DURATION" -output="result.bin" 33 | vegeta report -inputs="result.bin" 34 | rm "result.bin" 35 | } 36 | finally 37 | { 38 | Pop-Location 39 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/vegeta/targets-async.txt: -------------------------------------------------------------------------------- 1 | POST http://localhost:5000/api/async 2 | Content-Type: application/json 3 | @insert1.json 4 | 5 | GET http://localhost:5000/api/async 6 | GET http://localhost:5000/api/async 7 | GET http://localhost:5000/api/async 8 | 9 | POST http://localhost:5000/api/async 10 | Content-Type: application/json 11 | @insert2.json 12 | 13 | GET http://localhost:5000/api/async 14 | GET http://localhost:5000/api/async 15 | GET http://localhost:5000/api/async -------------------------------------------------------------------------------- /test/EFCore.MySql.IntegrationTests/scripts/vegeta/targets-sync.txt: -------------------------------------------------------------------------------- 1 | POST http://localhost:5000/api/sync 2 | Content-Type: application/json 3 | @insert1.json 4 | 5 | GET http://localhost:5000/api/sync 6 | GET http://localhost:5000/api/sync 7 | GET http://localhost:5000/api/sync 8 | 9 | POST http://localhost:5000/api/sync 10 | Content-Type: application/json 11 | @insert2.json 12 | 13 | GET http://localhost:5000/api/sync 14 | GET http://localhost:5000/api/sync 15 | GET http://localhost:5000/api/sync -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | /config.json 2 | /.vscode 3 | -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // #define FIXED_TEST_ORDER 2 | 3 | using Xunit; 4 | 5 | // 6 | // Optional: Control the test execution order. 7 | // This can be helpful for diffing etc. 8 | // 9 | 10 | #if FIXED_TEST_ORDER 11 | 12 | [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true, MaxParallelThreads = 1)] 13 | [assembly: TestCollectionOrderer("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlTestCollectionOrderer", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 14 | [assembly: TestCaseOrderer("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlTestCaseOrderer", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 15 | 16 | #endif 17 | 18 | // Our custom MySqlXunitTestFrameworkDiscoverer class allows filtering whole classes like SupportedServerVersionConditionAttribute, instead 19 | // of just the test cases. This is necessary, if a fixture is database server version dependent. 20 | [assembly: TestFramework("Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities.Xunit.MySqlXunitTestFramework", "Pomelo.EntityFrameworkCore.MySql.FunctionalTests")] 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/MySqlOptionsExtensionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; 4 | using Xunit; 5 | 6 | namespace Pomelo.EntityFrameworkCore.MySql 7 | { 8 | public class MySqlOptionsExtensionTest 9 | { 10 | [Fact] 11 | public void GetServiceProviderHashCode_returns_same_value() 12 | { 13 | Assert.Equal( 14 | new MySqlOptionsExtension().Info.GetServiceProviderHashCode(), 15 | new MySqlOptionsExtension().Info.GetServiceProviderHashCode()); 16 | 17 | Assert.Equal( 18 | new MySqlOptionsExtension() 19 | .WithServerVersion(new MySqlServerVersion(new Version(1, 2, 3, 4))) 20 | .WithDisabledBackslashEscaping() 21 | .Info 22 | .GetServiceProviderHashCode(), 23 | new MySqlOptionsExtension() 24 | .WithServerVersion(new MySqlServerVersion(new Version(1, 2, 3, 4))) 25 | .WithDisabledBackslashEscaping() 26 | .Info 27 | .GetServiceProviderHashCode()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/TestUtilities/BuildFileResult.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Pomelo.EntityFrameworkCore.TestUtilities 4 | { 5 | public class BuildFileResult 6 | { 7 | public BuildFileResult(string targetPath) 8 | { 9 | TargetPath = targetPath; 10 | TargetDir = Path.GetDirectoryName(targetPath); 11 | TargetName = Path.GetFileNameWithoutExtension(targetPath); 12 | } 13 | 14 | public string TargetPath { get; } 15 | 16 | public string TargetDir { get; } 17 | 18 | public string TargetName { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/TestUtilities/ListDiagnosticSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | 8 | namespace Microsoft.EntityFrameworkCore.TestUtilities 9 | { 10 | public class ListDiagnosticSource : DiagnosticSource 11 | { 12 | public ListDiagnosticSource(List<Tuple<string, object>> diagnosticList) 13 | { 14 | DiagnosticList = diagnosticList; 15 | } 16 | 17 | public List<Tuple<string, object>> DiagnosticList { get; } 18 | 19 | public override void Write(string diagnosticName, object parameters) 20 | => DiagnosticList?.Add(new Tuple<string, object>(diagnosticName, parameters)); 21 | 22 | public override bool IsEnabled(string diagnosticName) => true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/config.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "Data": { 3 | "ConnectionString": "server=127.0.0.1;user id=root;password=Password12!;port=3306;sslmode=none;", 4 | "ServerVersion": "auto", 5 | "CommandTimeout": "600" 6 | } 7 | } -------------------------------------------------------------------------------- /test/EFCore.MySql.Tests/dotnet-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" 4 | export PATH="$DOTNET_HOME:$PATH" 5 | exec "$@" 6 | -------------------------------------------------------------------------------- /test/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "appDomain": "denied" 3 | } 4 | -------------------------------------------------------------------------------- /tools/QueryBaselineUpdater/QueryBaselineUpdater.csproj: -------------------------------------------------------------------------------- 1 | <Project Sdk="Microsoft.NET.Sdk"> 2 | 3 | <PropertyGroup> 4 | <OutputType>Exe</OutputType> 5 | <TargetFramework>$(PomeloTestTargetFramework)</TargetFramework> 6 | </PropertyGroup> 7 | 8 | </Project> 9 | --------------------------------------------------------------------------------