diff --git a/CHANGES b/CHANGES
index cf700e975..5de140640 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,88 @@
+9.4.0
+- Fixed bug OpenAsync throws unhandled exception from thread pool (MySQL Bug #110789, Oracle Bug #35474099).
+- Fixed Entity Framework 6 from NET9 is deprecated due to Nunit4 Upgrade (MySQL Bug #117976, Oracle Bug #37837374).
+- Added support for GSSAPI/Kerberos authentication on Windows using authentication_ldap_sasl_client plug-in (WL15984).
+- Added support for .NET 10 and EF Core 10 preview versions (WL16900).
+- Fixed MySql.EntityFrameworkCore 8.0.8 rename bug (MySQL Bug #116704, Oracle Bug #37462099).
+- Fixed Invalid cast exception (MySQL Bug #118282, Oracle Bug #38001821). Thanks to Dev Nullinside for the contribution.
+- Fixed MySqlHelper.ExecuteReaderAsync causes stack overflow (MySQL Bug #114006, Oracle Bug #36303124).
+- Fixed bug Connector/Net Not honouring MinPoolSize Configuration (MySQL Bug #117020, Oracle Bug #37462116).
+- Fixed bug bugfix schema name (specially usefull when use multiple schema) (MySQL Bug #111030, Oracle Bug #35392218). Thanks to Stéphane Graziano for the contribution.
+- Fixed bug reorganize test suite (Oracle Bug #38029691).
+
+
+9.3.0
+- Fixed bug MySql.EntityFrameworkCore.dll in NuGet packages is not signed (Oracle Bug #37503859).
+- Fixed some tests due to incorrect implementation (WL16033).
+- Updated third party dependencies (WL16852).
+- Fixed bug Cannot Perform Database Migration using MySql.EntityFrameworkCore 9.0.0 (MySQL Bug #117258, Oracle Bug #37513445).
+- Fixed failing tests due to server changes (Oracle Bug #37705281).
+
+
+9.2.0
+- Added support for .NET 9 and EF Core 9 GA versions (WL16638).
+- Removed support for .NET 6 and EFCore 6 (WL16654).
+- Fixed bug Run inserts in batch command as one block (MySQL Bug #110553, Oracle Bug #35240186). Thanks to Sebastian Schwarzhuber for the contribution.
+- Fixed failing tests due to server changes (Oracle Bug #37365939).
+- Fixed bug Fix: MySQLUpdateSqlGenerator to inherit UpdateAndSelectSqlGenerator (MySQL Bug #115020, Oracle Bug #36624158). Thanks to Hikari Fujioka for the contribution.
+- Fixed bug Fixed NullReferenceException (MySQL Bug #114457, Oracle Bug #36568102). Thanks to Maximilian Bienhüls for the contribution.
+- Fixed bug MySql.Data.OpenTelemetry dll has a version 0.0.0.0 (Oracle Bug #37198051).
+- Fixed bug Missing VersionInfo file in multiple projects (Oracle Bug #37240118).
+- Fixed bug ConcurrencyFix - Added back in RowCount checking (MySQL Bug #115853, Oracle Bug #36960454). Thanks to Ryan Kelly for the contribution.
+
+
+9.1.0
+- Updated test suite to use constraint-based assertions (WL16397).
+- Changed testsuite to use assummptions instead of Assert.Ignore (WL16402).
+- Added support for .NET 9 and EFCore 9 preview versions (WL16308).
+- Added OpenTelemetry.Api NuGet package reference (WL16453).
+- Fixed Code coverage (WL16309).
+- Added support for OpenID Connect client authentication (WL16491).
+- Fixed bug 8.0.33 Removes Important Locks (MySQL Bug #111759, Oracle Bug #35937318). Thanks to Stuart Lang for the contribution.
+- Fixed bug EntityFramework SQL generation of TPT pseudo discriminator column incorrect (MySQL Bug #116028, Oracle Bug #37032982). Thanks to Kristoffer Sjöberg for the contribution.
+- Fixed bug Connector does crashes when retrieving data from the database (MySQL Bug #111630, Oracle Bug #35937293). Thanks to Sidraya Jayagond for the contribution.
+
+
+9.0.0
+- Updated NUnit to 4.x (WL16279).
+- Removed deprecated OldGetStringBehavior option (WL16280).
+- Remove MySqlX.Data.Performance.Console.Tests project (WL16387).
+- Updated third party dependencies (WL16291).
+- Remove .NET 7 and EF Core 7 (WL16386).
+- Fixed bug SQL Keyword "RETURNING" not handled properly when updating data (Oracle Bug #36116171). Thanks to Wang Shiyao for the contribution.
+- Fixed bug IIS Website is crashing after upgrading MySQL.Data package to 8.3.0 (Oracle Bug #36483069).
+- Updated Wix Toolset to 4.0.5 (Oracle Bug #36627858).
+- Fixed bug disabling of mysql_native_password in server causes errors in testsuite (Oracle Bug #36529814).
+- Fixed bug EFCore test failing due to misconfiguration (Oracle Bug #36701652).
+
+
+8.4.0
+- Updated FOSS license text in all source files (WL16197).
+- Fixed bug Shared memory connection doesn't work in multithread environment (Oracle Bug #36208932).
+- Fixed bug Named pipe connection doesn't work in multithread environment (Oracle Bug #36208929).
+- Fixed bug Byte array type mapping has a fixed limit of 8000 in EFCore (Oracle Bug #36208913).
+- Removed support for FIDO authentication (WL16150).
+- Add support for TLS 1.3 (WL16176).
+- Updated installer and binary metadata (WL16204).
+- Fixed bug Minpoolsize different than 0 causes connector to hang after first connection (Oracle Bug #36319784).
+- Fixed bug Tests failing due to removal of 'HAVE_SSL' variable from server (Oracle Bug #36374702).
+- Added support for Vector data type (WL16175).
+- Fixed bug Fix deadlock in mysql poolmanager attempt (Oracle Bug #36380976). Thanks to Marek Matys for the contribution.
+- Fixed bug Test failing due to removal of 'default_authentication_plugin' server variable (Oracle Bug #36405198).
+
+
+8.3.0
+- Added support for build traversal (WL15798).
+- Added AssemblyInfo file to MySQL.Data.OpenTelemetry (Oracle Bug #35957212).
+- Fix broken .GetString() behavior on MySqlDataReader (WL15972).
+- Fixed a bug that prevented a connection from being removed from the in use connection pool. (MySQL Bug #112123, Oracle Bug #35731216).
+- Added missing target frameworks to EFCore nuget packages (Oracle Bug #35968775).
+- Added missing README files to Nuget packages (WL16041).
+- Upgraded the Google.Protobuf dependency to version 3.25.1 (WL16075).
+- Added support for .NET 8 and EFCore 8 GA versions (WL16035).
+- Fixed a bug that permitted to open a disposed connection (MySQL bug #112399, Oracle bug #35827809).
+
+
8.2.0
- Migrated installer to Wix 4.0 (WL15847).
- Fixed bug Opening two MySqlConnections simultaneously can crash (Oracle Bug #35307501).
@@ -469,4 +554,4 @@
- Support for MySqlX.Session and NodeSession objects in new Dev API.
- Support for Collection and Documents objects new Dev API.
- Support for Relational tables in new Dev API.
-- Support for Transactions in new Dev API.
\ No newline at end of file
+- Support for Transactions in new Dev API.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 280a049de..e5612e3bd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,48 +1,65 @@
# Contributing Guidelines
-We love getting feedback from our users. Bugs and code contributions are great forms of feedback and we thank you for any bugs you report or code you contribute.
+We greatly appreciate feedback from our users, including bug reports and code contributions. Your input helps us improve, and we thank you for any issues you report or code you contribute.
## Reporting Issues
-Before reporting a new bug, please [check first](https://bugs.mysql.com/search.php) to see if a similar bug exists.
+Before submitting a new bug report, please [check here](https://bugs.mysql.com/search.php) to see if the issue has already been reported.
-Bug reports should be as complete as possible. Please try and include the following:
-* Complete steps to reproduce the issue.
-* Any information about platform and environment that could be specific to the bug.
-* Specific version of the product you are using.
-* Specific version of the server being used.
-* Sample code to help reproduce the issue if possible.
+When reporting a bug, ensure your report is as detailed as possible. Please include the following:
+
+* Clear, reproducible steps to demonstrate the issue.
+* Relevant platform and environment information.
+* The specific version of the product in use.
+* The version of the MySQL Server in use.
+* Sample code that can help reproduce the issue, if applicable.
## Contributing Code
-Contributing to this project is easy. You just need to follow these steps:
+We welcome your code contributions. Before submitting code via a GitHub pull request or by filing a bug on [bugs.mysql.com](https://bugs.mysql.com), you will need to sign the Oracle Contributor Agreement (OCA). Instructions for signing the OCA are available on the [OCA Page](https://oca.opensource.oracle.com).
+
+**Only pull requests from contributors who have signed the OCA can be accepted.**
+
+### Submitting a Contribution
-* Make sure you have a user account at [bugs.mysql.com](bugs.mysql.com). You'll need to reference this user account when you submit your OCA (Oracle Contributor Agreement).
-* Sign the Oracle OCA. You can find instructions for doing that at the [OCA Page](https://oca.opensource.oracle.com/).
-* Develop your pull request.
- * Make sure you are aware of the requirements for the project (e.g. don't require .NET Core 3.0 if we are curently supporting .NET Core 2.2 and lower).
-* Validate your pull request by including tests that sufficiently cover the functionality.
-* Verify that the entire test suite passes with your code applied.
-* Submit your pull request. While you can submit the pull request with [Github](https://github.com/mysql/mysql-connector-net/pulls), you can also submit it directly with [bugs.mysql.com](https://bugs.mysql.com).
+1. Ensure you have a user account at [bugs.mysql.com](https://bugs.mysql.com). You'll need to reference this account when submitting your OCA.
+2. Sign the Oracle Contributor Agreement. Instructions are provided on the [OCA Page](https://oca.opensource.oracle.com).
+3. Validate your contribution by including tests that adequately cover the functionality you're adding.
+4. Ensure the entire test suite passes with your changes applied.
+5. Submit your pull request through [GitHub](https://github.com/mysql/mysql-connector-net/pulls/) or upload it to a bug record on [bugs.mysql.com](https://bugs.mysql.com) using the _Contributions_ tab.
-Thanks again for being willing to contribute to MySQL. We truly believe in the principles of open source and appreciate any and all contributions to our projects.
+### Developing Your Pull Request
+
+1. Create your pull request, following the [project's requirements](https://dev.mysql.com/doc/connector-net/en/connector-net-installation.html).
+2. Include sufficient tests to validate the new functionality.
+3. Confirm that the entire test suite passes with your changes applied.
+4. Submit the pull request via [GitHub](https://github.com/mysql/mysql-connector-net/pulls/) or directly via [bugs.mysql.com](https://bugs.mysql.com).
+
+We deeply value contributions to MySQL and thank you for supporting open-source development.
## Setting Up a Development Environment
-You can use your preferred .NET IDE to view, edit, and compile the MySQL Connector/NET source code. The configuration setup can be adapted from [Installing from Source](https://dev.mysql.com/doc/connector-net/en/connector-net-installation-source.html).
+You can use your preferred .NET IDE to view, edit, and compile the MySQL Connector/NET source code. For project configuration, please refer to the instructions in [Installing from Source](https://dev.mysql.com/doc/connector-net/en/connector-net-installation-source.html).
## Running Tests
-Any code you contribute needs to pass our test suite, each of our projects have his own (e.g. MySql.Data.Tests). You must run the entire suite just to make sure that no other functionality have been affected by the change. You can run the test suite by using the IDE of your preference or by CLI with the help of the "dotnet" tool.
-
+Any code you contribute must pass our test suite. Each project has its own suite (e.g., *MySql.Data.Tests*). Be sure to run the entire test suite to ensure that no other functionality is affected by your changes. You can run the tests using your preferred IDE or via the CLI with the "dotnet" tool.
+
## Getting Help
-If you need help or just want to get in touch with us, please use the following resources:
+If you need assistance or would like to reach out to the community, please use the following resources:
-* [MySQL Connector/NET and C# forum](https://forums.mysql.com/list.php?38)
-* [MySQL NuGet](https://www.nuget.org/profiles/MySQL)
-* [MySQL Bugs database](https://bugs.mysql.com/)
+* [MySQL Connector/NET Developer Guide](https://dev.mysql.com/doc/connector-net/en/)
+* [MySQL Connector/NET API](https://dev.mysql.com/doc/dev/connector-net/latest/)
+* [MySQL NuGet](https://www.nuget.org/profiles/MySQL/)
+* [MySQL Connector/NET and C#, Mono, .Net Forum](https://forums.mysql.com/list.php?38)
+* [`#connectors` channel on MySQL Community Slack](https://mysqlcommunity.slack.com/messages/connectors/) ([Sign-up](https://lefred.be/mysql-community-on-slack/) required if you do not have an Oracle account.)
+* [@MySQL on X](https://x.com/MySQL/).
+* [MySQL Blog](https://blogs.oracle.com/mysql/).
+* [MySQL Connectors Blog archive](https://dev.mysql.com/blog-archive/?cat=Connectors%20%2F%20Languages).
+* [MySQL Newsletter](https://www.mysql.com/news-and-events/newsletter/).
+* [MySQL Bugs Tracking System](https://bugs.mysql.com).
-We hope to hear from you soon. Enjoy your coding!
+We look forward to hearing from you and encourage you to get involved. Happy coding!
-[](https://twitter.com/intent/follow?screen_name=MySQL)
\ No newline at end of file
+[](https://x.com/intent/follow?screen_name=MySQL)
diff --git a/Dependencies/MITLibs/comerr64.dll b/Dependencies/MITLibs/comerr64.dll
index 0a48cb5b6..70753cc79 100644
Binary files a/Dependencies/MITLibs/comerr64.dll and b/Dependencies/MITLibs/comerr64.dll differ
diff --git a/Dependencies/MITLibs/gssapi64.dll b/Dependencies/MITLibs/gssapi64.dll
index 1628e3842..21d6feb38 100644
Binary files a/Dependencies/MITLibs/gssapi64.dll and b/Dependencies/MITLibs/gssapi64.dll differ
diff --git a/Dependencies/MITLibs/k5sprt64.dll b/Dependencies/MITLibs/k5sprt64.dll
index 9237ce9d7..ff77f1a3b 100644
Binary files a/Dependencies/MITLibs/k5sprt64.dll and b/Dependencies/MITLibs/k5sprt64.dll differ
diff --git a/Dependencies/MITLibs/krb5_64.dll b/Dependencies/MITLibs/krb5_64.dll
index 582f680f8..42db6f7b1 100644
Binary files a/Dependencies/MITLibs/krb5_64.dll and b/Dependencies/MITLibs/krb5_64.dll differ
diff --git a/Dependencies/MITLibs/krbcc64.dll b/Dependencies/MITLibs/krbcc64.dll
index ba5a5190d..c3891e817 100644
Binary files a/Dependencies/MITLibs/krbcc64.dll and b/Dependencies/MITLibs/krbcc64.dll differ
diff --git a/Dependencies/OpenTelemetry.Api/OpenTelemetry.Api.dll b/Dependencies/OpenTelemetry.Api/OpenTelemetry.Api.dll
deleted file mode 100644
index 9f8aee47f..000000000
Binary files a/Dependencies/OpenTelemetry.Api/OpenTelemetry.Api.dll and /dev/null differ
diff --git a/Documentation/docfx.json b/Documentation/docfx.json
index 0989b6025..f194fe7e3 100644
--- a/Documentation/docfx.json
+++ b/Documentation/docfx.json
@@ -28,7 +28,7 @@
}
],
"dest": "api/efcore_api",
- "properties": { "TargetFramework": "net7.0" }
+ "properties": { "TargetFramework": "net9.0" }
},
{
"src": [
@@ -77,7 +77,7 @@
}
],
"globalMetadata": {
- "_appFooter": "Copyright © 2021, 2023, Oracle and/or its affiliates.",
+ "_appFooter": "Copyright © 2021, 2025, Oracle and/or its affiliates.",
"_appLogoPath": "/images/logo.svg",
"_appFaviconPath": "/images/favicon.ico",
"_enableSearch": true
@@ -86,4 +86,4 @@
"markdownEngineName": "markdig",
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ]
}
-}
\ No newline at end of file
+}
diff --git a/Documentation/index.md b/Documentation/index.md
index ad6cc25d6..8fed932d0 100644
--- a/Documentation/index.md
+++ b/Documentation/index.md
@@ -1,6 +1,6 @@
## MySQL Connector/NET and X DevAPI
-MySQL Connector/NET 8.2 supports X Protocol, which enables you to use X DevAPI with the .NET language of choice to develop applications that communicate with a MySQL server functioning as a document store, relational database, or both.
+MySQL Connector/NET 9.4 supports X Protocol, which enables you to use X DevAPI with the .NET language of choice to develop applications that communicate with a MySQL server functioning as a document store, relational database, or both.
To get started, review the following main classes:
@@ -16,7 +16,7 @@ For an introduction to X DevAPI concepts, see the [X DevAPI User Guide](https://
## MySQL Connector/NET
-MySQL Connector/NET 8.2 also supports the development of .NET, .NET Core and .NET Framework applications that require secure, high-performance data connectivity with MySQL through the classic protocol. It supports ADO.NET, Entity Framework and various web providers.
+MySQL Connector/NET 9.4 also supports the development of .NET, .NET Core and .NET Framework applications that require secure, high-performance data connectivity with MySQL through the classic protocol. It supports ADO.NET, Entity Framework and various web providers.
To get started, review the following main classes:
diff --git a/Documentation/templates/custom/partials/class.header.tmpl.partial b/Documentation/templates/custom/partials/class.header.tmpl.partial
index 9a663a1e5..f545c2864 100644
--- a/Documentation/templates/custom/partials/class.header.tmpl.partial
+++ b/Documentation/templates/custom/partials/class.header.tmpl.partial
@@ -25,7 +25,7 @@
{{/implements.0}}
{{syntax.content.0.value}}
diff --git a/EFCore/Directory.Build.targets b/EFCore/Directory.Build.targets
deleted file mode 100644
index 08bf7e756..000000000
--- a/EFCore/Directory.Build.targets
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- Copyright (c) 2021, 2023, Oracle and/or its affiliates.
- 6.0.21+MySQL8.2.0
-
-
-
- Copyright (c) 2022, 2023, Oracle and/or its affiliates.
- 7.0.10+MySQL8.2.0
-
-
-
- Copyright (c) 2023, Oracle and/or its affiliates.
- 8.0.0-preview+MySQL8.2.0
-
-
\ No newline at end of file
diff --git a/EFCore/src/DataAnnotations/MySQLCharsetAttribute.cs b/EFCore/src/DataAnnotations/MySQLCharsetAttribute.cs
index 93341796a..6541f6d5e 100644
--- a/EFCore/src/DataAnnotations/MySQLCharsetAttribute.cs
+++ b/EFCore/src/DataAnnotations/MySQLCharsetAttribute.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/DataAnnotations/MySQLCollationAttribute.cs b/EFCore/src/DataAnnotations/MySQLCollationAttribute.cs
index a5096091c..53cdb1bb8 100644
--- a/EFCore/src/DataAnnotations/MySQLCollationAttribute.cs
+++ b/EFCore/src/DataAnnotations/MySQLCollationAttribute.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Design/Internal/MySQLAnnotationCodeGenerator.cs b/EFCore/src/Design/Internal/MySQLAnnotationCodeGenerator.cs
index c784b531f..4fce96898 100644
--- a/EFCore/src/Design/Internal/MySQLAnnotationCodeGenerator.cs
+++ b/EFCore/src/Design/Internal/MySQLAnnotationCodeGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Design/Internal/MySQLDesignTimeServices.cs b/EFCore/src/Design/Internal/MySQLDesignTimeServices.cs
index 145c197a1..30389cea5 100644
--- a/EFCore/src/Design/Internal/MySQLDesignTimeServices.cs
+++ b/EFCore/src/Design/Internal/MySQLDesignTimeServices.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Diagnostics/Internal/MySQLLoggingDefinitions.cs b/EFCore/src/Diagnostics/Internal/MySQLLoggingDefinitions.cs
index 0eb84c2b6..6ac04605a 100644
--- a/EFCore/src/Diagnostics/Internal/MySQLLoggingDefinitions.cs
+++ b/EFCore/src/Diagnostics/Internal/MySQLLoggingDefinitions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -64,4 +64,4 @@ internal class MySQLLoggingDefinitions : RelationalLoggingDefinitions
public EventDefinitionBase? LogReflexiveConstraintIgnored;
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Diagnostics/MySQLEventId.cs b/EFCore/src/Diagnostics/MySQLEventId.cs
index 571f75f12..e2a639ea6 100644
--- a/EFCore/src/Diagnostics/MySQLEventId.cs
+++ b/EFCore/src/Diagnostics/MySQLEventId.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -187,4 +187,4 @@ private enum Id
///
public static readonly EventId ReflexiveConstraintIgnored = MakeScaffoldingId(Id.ReflexiveConstraintIgnored);
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Extensions/MySQLDatabaseFacadeExtensions.cs b/EFCore/src/Extensions/MySQLDatabaseFacadeExtensions.cs
index 585b4a51d..43f02dfe9 100644
--- a/EFCore/src/Extensions/MySQLDatabaseFacadeExtensions.cs
+++ b/EFCore/src/Extensions/MySQLDatabaseFacadeExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLDbContextOptionsExtensions.cs b/EFCore/src/Extensions/MySQLDbContextOptionsExtensions.cs
index 50072cf32..9cc0b5150 100644
--- a/EFCore/src/Extensions/MySQLDbContextOptionsExtensions.cs
+++ b/EFCore/src/Extensions/MySQLDbContextOptionsExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -201,4 +201,4 @@ var coreOptionsExtension
((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(coreOptionsExtension);
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Extensions/MySQLDbFunctionsEnums.cs b/EFCore/src/Extensions/MySQLDbFunctionsEnums.cs
index cc8e6a5b6..48e224773 100644
--- a/EFCore/src/Extensions/MySQLDbFunctionsEnums.cs
+++ b/EFCore/src/Extensions/MySQLDbFunctionsEnums.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLDbFunctionsExtensions.cs b/EFCore/src/Extensions/MySQLDbFunctionsExtensions.cs
index 4e10401c6..6cc956262 100644
--- a/EFCore/src/Extensions/MySQLDbFunctionsExtensions.cs
+++ b/EFCore/src/Extensions/MySQLDbFunctionsExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLEntityTypeBuilderExtensions.cs b/EFCore/src/Extensions/MySQLEntityTypeBuilderExtensions.cs
index cf19851e7..33bc3b1e4 100644
--- a/EFCore/src/Extensions/MySQLEntityTypeBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySQLEntityTypeBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLEntityTypeExtensions.cs b/EFCore/src/Extensions/MySQLEntityTypeExtensions.cs
index ed70a8753..9eec6cc26 100644
--- a/EFCore/src/Extensions/MySQLEntityTypeExtensions.cs
+++ b/EFCore/src/Extensions/MySQLEntityTypeExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLIndexExtensions.cs b/EFCore/src/Extensions/MySQLIndexExtensions.cs
index b6e6984c6..bc4be7b3c 100644
--- a/EFCore/src/Extensions/MySQLIndexExtensions.cs
+++ b/EFCore/src/Extensions/MySQLIndexExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -194,4 +194,4 @@ public static int[] SetPrefixLength([NotNull] this IConventionIndex index, int[]
public static ConfigurationSource? GetPrefixLengthConfigurationSource([NotNull] this IConventionIndex property)
=> property.FindAnnotation(MySQLAnnotationNames.IndexPrefixLength)?.GetConfigurationSource();
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Extensions/MySQLKeyBuilderExtensions.cs b/EFCore/src/Extensions/MySQLKeyBuilderExtensions.cs
index e60b9a12d..72727aefb 100644
--- a/EFCore/src/Extensions/MySQLKeyBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySQLKeyBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLKeyExtensions.cs b/EFCore/src/Extensions/MySQLKeyExtensions.cs
index 5481669a3..2be6817e1 100644
--- a/EFCore/src/Extensions/MySQLKeyExtensions.cs
+++ b/EFCore/src/Extensions/MySQLKeyExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLMigrationBuilderExtensions.cs b/EFCore/src/Extensions/MySQLMigrationBuilderExtensions.cs
index ddb6a689d..6aef77044 100644
--- a/EFCore/src/Extensions/MySQLMigrationBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySQLMigrationBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLModelBuilderExtensions.cs b/EFCore/src/Extensions/MySQLModelBuilderExtensions.cs
index e6a07340f..89a4a2801 100644
--- a/EFCore/src/Extensions/MySQLModelBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySQLModelBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLModelExtensions.cs b/EFCore/src/Extensions/MySQLModelExtensions.cs
index 932546941..f2284ec4f 100644
--- a/EFCore/src/Extensions/MySQLModelExtensions.cs
+++ b/EFCore/src/Extensions/MySQLModelExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLPropertyBuilderExtensions.cs b/EFCore/src/Extensions/MySQLPropertyBuilderExtensions.cs
index edd95f691..88729618a 100644
--- a/EFCore/src/Extensions/MySQLPropertyBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySQLPropertyBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Extensions/MySQLPropertyExtensions.cs b/EFCore/src/Extensions/MySQLPropertyExtensions.cs
index 27b3b44cb..ebc0ebed1 100644
--- a/EFCore/src/Extensions/MySQLPropertyExtensions.cs
+++ b/EFCore/src/Extensions/MySQLPropertyExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -253,4 +253,4 @@ private static void CheckValueGenerationStrategy(IReadOnlyProperty property, MyS
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Extensions/MySQLServiceCollectionExtensions.cs b/EFCore/src/Extensions/MySQLServiceCollectionExtensions.cs
index db08f46e5..42317fa9b 100644
--- a/EFCore/src/Extensions/MySQLServiceCollectionExtensions.cs
+++ b/EFCore/src/Extensions/MySQLServiceCollectionExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -168,4 +168,4 @@ public static IServiceCollection AddEntityFrameworkMySQL(this IServiceCollection
return services;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Extensions/MySQLTypeBaseExtensions.cs b/EFCore/src/Extensions/MySQLTypeBaseExtensions.cs
new file mode 100644
index 000000000..ba1e608bc
--- /dev/null
+++ b/EFCore/src/Extensions/MySQLTypeBaseExtensions.cs
@@ -0,0 +1,60 @@
+// Copyright © 2023, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using Microsoft.EntityFrameworkCore.Metadata;
+using MySql.EntityFrameworkCore.Metadata.Internal;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MySql.EntityFrameworkCore.Extensions
+{
+ ///
+ /// MySQL extension methods for type base.
+ ///
+ public static class MySQLTypeBaseExtensions
+ {
+ ///
+ /// Gets the MySQL character set for the table associated with this TypeBase.
+ ///
+ ///
The TypeBase.
+ ///
The name of the character set.
+ public static string? GetCharSet([NotNull] this IReadOnlyTypeBase typeBase)
+ => typeBase[MySQLAnnotationNames.Charset] as string;
+
+ ///
+ /// Gets the MySQL collation for the table associated with this TypeBase.
+ ///
+ ///
The TypeBase.
+ ///
The name of the collation.
+ public static string? GetCollation([NotNull] this IReadOnlyTypeBase typeBase)
+ => typeBase[RelationalAnnotationNames.Collation] as string;
+ }
+}
diff --git a/EFCore/src/Extensions/MySqlIndexBuilderExtensions.cs b/EFCore/src/Extensions/MySqlIndexBuilderExtensions.cs
index 6409ac85a..43257933f 100644
--- a/EFCore/src/Extensions/MySqlIndexBuilderExtensions.cs
+++ b/EFCore/src/Extensions/MySqlIndexBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Infrastructure/Internal/IMySQLOptions.cs b/EFCore/src/Infrastructure/Internal/IMySQLOptions.cs
index 4252d8677..116f21644 100644
--- a/EFCore/src/Infrastructure/Internal/IMySQLOptions.cs
+++ b/EFCore/src/Infrastructure/Internal/IMySQLOptions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -52,4 +52,4 @@ public interface IMySQLOptions : ISingletonOptions
///
The SchemaNameTranslator.
MySQLSchemaNameTranslator? SchemaNameTranslator { get; }
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Infrastructure/Internal/MySQLOptionsExtension.cs b/EFCore/src/Infrastructure/Internal/MySQLOptionsExtension.cs
index 0231be384..e2fc4616d 100644
--- a/EFCore/src/Infrastructure/Internal/MySQLOptionsExtension.cs
+++ b/EFCore/src/Infrastructure/Internal/MySQLOptionsExtension.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -153,4 +153,4 @@ public override void PopulateDebugInfo(IDictionary
debugInfo)
= (Extension.CharSet?.GetHashCode() ?? 0L).ToString(CultureInfo.InvariantCulture);
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Infrastructure/MySQLDbContextOptionsBuilder.cs b/EFCore/src/Infrastructure/MySQLDbContextOptionsBuilder.cs
index cae15cd48..b01a40fcf 100644
--- a/EFCore/src/Infrastructure/MySQLDbContextOptionsBuilder.cs
+++ b/EFCore/src/Infrastructure/MySQLDbContextOptionsBuilder.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Infrastructure/MySQLSchemaBehavior.cs b/EFCore/src/Infrastructure/MySQLSchemaBehavior.cs
index acb63a8df..75f1002e7 100644
--- a/EFCore/src/Infrastructure/MySQLSchemaBehavior.cs
+++ b/EFCore/src/Infrastructure/MySQLSchemaBehavior.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Internal/MySQLModelValidator.cs b/EFCore/src/Internal/MySQLModelValidator.cs
index adebfc755..3ffd0388f 100644
--- a/EFCore/src/Internal/MySQLModelValidator.cs
+++ b/EFCore/src/Internal/MySQLModelValidator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -48,4 +48,4 @@ public override void Validate(IModel model, IDiagnosticsLogger
/// Represents a character-set attribute for an entity.
///
@@ -58,4 +59,30 @@ protected override void ProcessEntityTypeAdded(
true);
}
}
+#else
+ ///
+ /// Represents a character-set attribute for a Type.
+ ///
+ internal class MySqlEntityCharsetAttributeConvention : TypeAttributeConventionBase
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Parameter object containing dependencies for this convention.
+ public MySqlEntityCharsetAttributeConvention([NotNull] ProviderConventionSetBuilderDependencies dependencies)
+ : base(dependencies)
+ { }
+
+ protected override void ProcessEntityTypeAdded(
+ [NotNull] IConventionEntityTypeBuilder entityTypeBuilder,
+ [NotNull] MySQLCharsetAttribute attribute,
+ [NotNull] IConventionContext context)
+ {
+ entityTypeBuilder.Metadata.SetAnnotation(
+ MySQLAnnotationNames.Charset,
+ attribute.Charset,
+ true);
+ }
+ }
+#endif
}
diff --git a/EFCore/src/Metadata/Conventions/MySqlEntityCollationAttributeConvention.cs b/EFCore/src/Metadata/Conventions/MySqlEntityCollationAttributeConvention.cs
index 966e485bc..5c2ea15c3 100644
--- a/EFCore/src/Metadata/Conventions/MySqlEntityCollationAttributeConvention.cs
+++ b/EFCore/src/Metadata/Conventions/MySqlEntityCollationAttributeConvention.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
namespace MySql.EntityFrameworkCore.Metadata.Conventions
{
+#if !NET8_0_OR_GREATER
///
/// Represents a collation attribute for an entity.
///
@@ -58,4 +59,30 @@ protected override void ProcessEntityTypeAdded(
true);
}
}
+#else
+ ///
+ /// Represents a collation attribute for an Type.
+ ///
+ internal class MySqlEntityCollationAttributeConvention : TypeAttributeConventionBase
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Parameter object containing dependencies for this convention.
+ internal MySqlEntityCollationAttributeConvention([NotNull] ProviderConventionSetBuilderDependencies dependencies)
+ : base(dependencies)
+ { }
+
+ protected override void ProcessEntityTypeAdded(
+ [NotNull] IConventionEntityTypeBuilder entityTypeBuilder,
+ [NotNull] MySQLCollationAttribute attribute,
+ [NotNull] IConventionContext context)
+ {
+ entityTypeBuilder.Metadata.SetAnnotation(
+ MySQLAnnotationNames.Collation,
+ attribute.Collation,
+ true);
+ }
+ }
+#endif
}
diff --git a/EFCore/src/Metadata/Internal/MySQLAnnotationNames.cs b/EFCore/src/Metadata/Internal/MySQLAnnotationNames.cs
index 1678ca30a..b60e8c7ca 100644
--- a/EFCore/src/Metadata/Internal/MySQLAnnotationNames.cs
+++ b/EFCore/src/Metadata/Internal/MySQLAnnotationNames.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Metadata/Internal/MySQLAnnotationProvider.cs b/EFCore/src/Metadata/Internal/MySQLAnnotationProvider.cs
index f6174f88e..15783391d 100644
--- a/EFCore/src/Metadata/Internal/MySQLAnnotationProvider.cs
+++ b/EFCore/src/Metadata/Internal/MySQLAnnotationProvider.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -29,6 +29,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
using MySql.EntityFrameworkCore.Extensions;
using MySql.EntityFrameworkCore.Infrastructure.Internal;
using MySql.EntityFrameworkCore.Storage.Internal;
@@ -69,15 +70,21 @@ public override IEnumerable For(ITable table, bool designTime)
{
yield break;
}
+#if NET8_0_OR_GREATER
+ var entityType = table.EntityTypeMappings.First().TypeBase;
+ if (GetActualTypeBaseCharSet(entityType) is string charSet)
+ yield return new Annotation(MySQLAnnotationNames.Charset, charSet);
+ if (GetActualTypeBaseCollation(entityType) is string collation)
+ yield return new Annotation(RelationalAnnotationNames.Collation, collation);
+#else
var entityType = table.EntityTypeMappings.First().EntityType;
-
if (GetActualEntityTypeCharSet(entityType) is string charSet)
yield return new Annotation(MySQLAnnotationNames.Charset, charSet);
if (GetActualEntityTypeCollation(entityType) is string collation)
yield return new Annotation(RelationalAnnotationNames.Collation, collation);
-
+#endif
foreach (var annotation in entityType.GetAnnotations().Where(a => a.Name is MySQLAnnotationNames.StoreOptions))
yield return annotation;
}
@@ -118,7 +125,6 @@ public override IEnumerable For(ITableIndex index, bool designTime)
yield return new Annotation(MySQLAnnotationNames.SpatialIndex, isSpatial.Value);
}
-#if NET6_0
public override IEnumerable For(IColumn column, bool designTime)
{
if (!designTime)
@@ -126,48 +132,25 @@ public override IEnumerable For(IColumn column, bool designTime)
var table = StoreObjectIdentifier.Table(column.Table.Name, column.Table.Schema);
var properties = column.PropertyMappings.Select(m => m.Property).ToArray();
-
- if (column.PropertyMappings.Where(
- m => m.TableMapping.IsSharedTablePrincipal && m.TableMapping.EntityType == m.Property.DeclaringEntityType)
- .Select(m => m.Property)
- .FirstOrDefault(p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn) is IProperty identityProperty)
- {
- var valueGenerationStrategy = identityProperty.GetValueGenerationStrategy(table);
- yield return new Annotation(MySQLAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy);
- }
- else if (properties.FirstOrDefault
- (p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.ComputedColumn) is IProperty computedProperty)
- {
- var valueGenerationStrategy = computedProperty.GetValueGenerationStrategy(table);
- yield return new Annotation(MySQLAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy);
- }
- }
-#elif NET7_0 || NET8_0
- public override IEnumerable For(IColumn column, bool designTime)
- {
- if (!designTime)
- yield break;
-
- var table = StoreObjectIdentifier.Table(column.Table.Name, column.Table.Schema);
- var properties = column.PropertyMappings.Select(m => m.Property).ToArray();
-
- if (column.PropertyMappings.Where(m => m.TableMapping.IsSharedTablePrincipal ?? true
- && m.TableMapping.EntityType == m.Property.DeclaringEntityType)
- .Select(m => m.Property)
- .FirstOrDefault(p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn) is IProperty identityProperty)
+#if NET8_0_OR_GREATER
+ if (column.PropertyMappings.Where(m => m.TableMapping.IsSharedTablePrincipal ?? true && m.TableMapping.TypeBase == m.Property.DeclaringType)
+ .Select(m => m.Property)
+ .FirstOrDefault(p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn) is IProperty identityProperty)
+#else
+ if (column.PropertyMappings.Where(m => m.TableMapping.IsSharedTablePrincipal && m.TableMapping.EntityType == m.Property.DeclaringEntityType)
+ .Select(m => m.Property)
+ .FirstOrDefault(p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn) is IProperty identityProperty)
+#endif
{
var valueGenerationStrategy = identityProperty.GetValueGenerationStrategy(table);
yield return new Annotation(MySQLAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy);
}
- else if (properties.FirstOrDefault
- (p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.ComputedColumn) is IProperty computedProperty)
+ else if (properties.FirstOrDefault(p => p.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.ComputedColumn) is IProperty computedProperty)
{
var valueGenerationStrategy = computedProperty.GetValueGenerationStrategy(table);
yield return new Annotation(MySQLAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy);
}
}
-#endif
-
protected virtual string GetActualModelCharSet(IModel model)
{
@@ -179,6 +162,59 @@ protected virtual string GetActualModelCollation(IModel model)
return model.GetCollation()!;
}
+#if NET8_0_OR_GREATER
+ protected virtual string? GetActualTypeBaseCharSet(ITypeBase typeBase)
+ {
+ var typeBaseCharSet = typeBase.GetCharSet();
+
+ if (typeBaseCharSet is not null)
+ return typeBaseCharSet;
+
+ if (typeBaseCharSet is null)
+ {
+ var typeBaseCollation = typeBase.GetCollation();
+ var actualModelCharSet = GetActualModelCharSet(typeBase.Model);
+
+ if (typeBaseCollation is not null)
+ {
+ return actualModelCharSet is not null && typeBaseCollation.StartsWith(actualModelCharSet, StringComparison.OrdinalIgnoreCase)
+ ? actualModelCharSet : null;
+ }
+
+ var actualModelCollation = GetActualModelCollation(typeBase.Model);
+
+ if (actualModelCollation is not null)
+ {
+ return actualModelCharSet is not null && actualModelCollation.StartsWith(actualModelCharSet, StringComparison.OrdinalIgnoreCase)
+ ? actualModelCharSet : null;
+ }
+ return actualModelCharSet;
+ }
+ return null;
+ }
+
+ protected virtual string? GetActualTypeBaseCollation(ITypeBase typeBase)
+ {
+ var typeBaseCollation = typeBase.GetCollation();
+
+ if (typeBaseCollation is not null)
+ return typeBaseCollation;
+
+ if (typeBaseCollation is null)
+ {
+ var typeBaseCharSet = typeBase.GetCharSet();
+ var actualModelCollation = GetActualModelCollation(typeBase.Model);
+
+ if (typeBaseCharSet is not null)
+ {
+ return actualModelCollation is not null && actualModelCollation.StartsWith(typeBaseCharSet, StringComparison.OrdinalIgnoreCase)
+ ? actualModelCollation : null;
+ }
+ return actualModelCollation;
+ }
+ return null;
+ }
+#else
protected virtual string? GetActualEntityTypeCharSet(IEntityType entityType)
{
var entityTypeCharSet = entityType.GetCharSet();
@@ -204,10 +240,8 @@ protected virtual string GetActualModelCollation(IModel model)
return actualModelCharSet is not null && actualModelCollation.StartsWith(actualModelCharSet, StringComparison.OrdinalIgnoreCase)
? actualModelCharSet : null;
}
-
return actualModelCharSet;
}
-
return null;
}
@@ -228,25 +262,38 @@ protected virtual string GetActualModelCollation(IModel model)
return actualModelCollation is not null && actualModelCollation.StartsWith(entityTypeCharSet, StringComparison.OrdinalIgnoreCase)
? actualModelCollation : null;
}
-
return actualModelCollation;
}
-
return null;
}
+#endif
protected virtual string? GetActualPropertyCharSet(IProperty[] properties)
{
+#if NET8_0_OR_GREATER
+ return properties.Select(p => p.GetCharSet()).FirstOrDefault(s => s is not null) ??
+ properties.Select(
+ p => p.FindTypeMapping() is MySQLStringTypeMapping
+ ? GetActualTypeBaseCharSet(p.DeclaringType) is string charSet &&
+ (p.GetCollation() is not string collation ||
+ collation.StartsWith(charSet, StringComparison.OrdinalIgnoreCase))
+ ? charSet
+ : null
+ : null)
+ .FirstOrDefault(s => s is not null);
+ }
+#else
return properties.Select(p => p.GetCharSet()).FirstOrDefault(s => s is not null) ??
properties.Select(
- p => p.FindTypeMapping() is MySQLStringTypeMapping
- ? GetActualEntityTypeCharSet(p.DeclaringEntityType) is string charSet &&
- (p.GetCollation() is not string collation ||
- collation.StartsWith(charSet, StringComparison.OrdinalIgnoreCase))
- ? charSet
- : null
- : null)
+ p => p.FindTypeMapping() is MySQLStringTypeMapping
+ ? GetActualEntityTypeCharSet(p.DeclaringEntityType) is string charSet &&
+ (p.GetCollation() is not string collation ||
+ collation.StartsWith(charSet, StringComparison.OrdinalIgnoreCase))
+ ? charSet
+ : null
+ : null)
.FirstOrDefault(s => s is not null);
}
+#endif
}
}
diff --git a/EFCore/src/Metadata/MySQLValueGenerationStrategy.cs b/EFCore/src/Metadata/MySQLValueGenerationStrategy.cs
index f45079ded..730a80900 100644
--- a/EFCore/src/Metadata/MySQLValueGenerationStrategy.cs
+++ b/EFCore/src/Metadata/MySQLValueGenerationStrategy.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Migrations/Internal/MySQLHistoryRepository.cs b/EFCore/src/Migrations/Internal/MySQLHistoryRepository.cs
index fbf859f28..ce1c8d1f0 100644
--- a/EFCore/src/Migrations/Internal/MySQLHistoryRepository.cs
+++ b/EFCore/src/Migrations/Internal/MySQLHistoryRepository.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -27,12 +27,15 @@
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using MySql.EntityFrameworkCore.Utils;
using System;
using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
namespace MySql.EntityFrameworkCore.Migrations.Internal
{
@@ -50,7 +53,89 @@ public MySQLHistoryRepository([NotNull] HistoryRepositoryDependencies dependenci
: base(dependencies)
{
}
+#if NET9_0_OR_GREATER
+ public override LockReleaseBehavior LockReleaseBehavior => LockReleaseBehavior.Connection;
+ public override IMigrationsDatabaseLock AcquireDatabaseLock()
+ {
+ Dependencies.MigrationsLogger.AcquiringMigrationLock();
+
+ var dbLock = CreateMigrationDatabaseLock();
+ Int64 result;
+ try
+ {
+ result = (Int64)CreateGetLockCommand().ExecuteScalar(CreateRelationalCommandParameters())!;
+ }
+ catch
+ {
+ try
+ {
+ dbLock.Dispose();
+ }
+ catch
+ {
+ }
+
+ throw;
+ }
+
+ return result < 0
+ ? throw new TimeoutException()
+ : dbLock;
+ }
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public override async Task AcquireDatabaseLockAsync(CancellationToken cancellationToken = default)
+ {
+ Dependencies.MigrationsLogger.AcquiringMigrationLock();
+
+ var dbLock = CreateMigrationDatabaseLock();
+ Int64 result;
+ try
+ {
+ result = (Int64)(await CreateGetLockCommand().ExecuteScalarAsync(CreateRelationalCommandParameters(), cancellationToken)
+ .ConfigureAwait(false))!;
+ }
+ catch
+ {
+ try
+ {
+ await dbLock.DisposeAsync().ConfigureAwait(false);
+ }
+ catch
+ {
+ }
+
+ throw;
+ }
+
+ return result < 0
+ ? throw new TimeoutException()
+ : dbLock;
+ }
+
+ private IRelationalCommand CreateGetLockCommand()
+ => Dependencies.RawSqlCommandBuilder.Build("SELECT GET_LOCK('__EFMigrationsLock',-1);", []).RelationalCommand;
+
+ private MySQLMigrationDatabaseLock CreateMigrationDatabaseLock()
+ => new(
+ Dependencies.RawSqlCommandBuilder.Build("SELECT RELEASE_LOCK('__EFMigrationsLock');"),
+ CreateRelationalCommandParameters(),
+ this);
+
+ private RelationalCommandParameterObject CreateRelationalCommandParameters()
+ => new(
+ Dependencies.Connection,
+ null,
+ null,
+ Dependencies.CurrentContext.Context,
+ Dependencies.CommandLogger, CommandSource.Migrations);
+#endif
protected override string ExistsSql
{
get
diff --git a/EFCore/src/Migrations/Internal/MySQLMigrationDatabaseLockcs.cs b/EFCore/src/Migrations/Internal/MySQLMigrationDatabaseLockcs.cs
new file mode 100644
index 000000000..668e43971
--- /dev/null
+++ b/EFCore/src/Migrations/Internal/MySQLMigrationDatabaseLockcs.cs
@@ -0,0 +1,53 @@
+// Copyright © 2024, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MySql.EntityFrameworkCore.Migrations.Internal
+{
+#if NET9_0_OR_GREATER
+ internal class MySQLMigrationDatabaseLock(
+ IRelationalCommand releaseLockCommand,
+ RelationalCommandParameterObject relationalCommandParameters,
+ IHistoryRepository historyRepository,
+ CancellationToken cancellationToken = default)
+ : IMigrationsDatabaseLock
+ {
+ public virtual IHistoryRepository HistoryRepository => historyRepository;
+
+ public void Dispose()
+ => releaseLockCommand.ExecuteScalar(relationalCommandParameters);
+
+ public async ValueTask DisposeAsync()
+ => await releaseLockCommand.ExecuteScalarAsync(relationalCommandParameters, cancellationToken).ConfigureAwait(false);
+ }
+#endif
+}
diff --git a/EFCore/src/Migrations/Internal/MySQLMigrationsModelDiffer.cs b/EFCore/src/Migrations/Internal/MySQLMigrationsModelDiffer.cs
index 640abaadb..63ad27fb2 100644
--- a/EFCore/src/Migrations/Internal/MySQLMigrationsModelDiffer.cs
+++ b/EFCore/src/Migrations/Internal/MySQLMigrationsModelDiffer.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -44,19 +44,17 @@ namespace MySql.EntityFrameworkCore.Migrations.Internal
internal class MySQLMigrationsModelDiffer : MigrationsModelDiffer
{
-#if NET6_0
+#if NET8_0
public MySQLMigrationsModelDiffer(
- [NotNull] IRelationalTypeMappingSource typeMappingSource,
- [NotNull] IMigrationsAnnotationProvider migrationsAnnotations,
- [NotNull] IChangeDetector changeDetector,
- [NotNull] IUpdateAdapterFactory updateAdapterFactory,
- [NotNull] CommandBatchPreparerDependencies commandBatchPreparerDependencies)
- : base(
- typeMappingSource,
- migrationsAnnotations,
- changeDetector,
- updateAdapterFactory,
- commandBatchPreparerDependencies)
+ [NotNull] IRelationalTypeMappingSource typeMappingSource,
+ [NotNull] IMigrationsAnnotationProvider migrationsAnnotations,
+ [NotNull] IRowIdentityMapFactory rowIdentityMapFactory,
+ [NotNull] CommandBatchPreparerDependencies commandBatchPreparerDependencies)
+ : base(
+ typeMappingSource,
+ migrationsAnnotations,
+ rowIdentityMapFactory,
+ commandBatchPreparerDependencies)
{
}
@@ -65,33 +63,35 @@ protected override IEnumerable Add(IColumn target, DiffConte
var _property = target.PropertyMappings.ToArray().FirstOrDefault()!.Property;
if (_property.FindTypeMapping() is RelationalTypeMapping storeType)
{
- var valueGenerationStrategy = MySQLValueGenerationStrategyCompatibility.GetValueGenerationStrategy(MigrationsAnnotations.ForRemove(target).ToArray());
+ var valueGenerationStrategy = MySQLValueGenerationStrategyCompatibility.GetValueGenerationStrategy(MigrationsAnnotationProvider.ForRemove(target).ToArray());
// Ensure that null will be set for the columns default value, if CURRENT_TIMESTAMP has been required,
// or when the store type of the column does not support default values at all.
inline = inline ||
- (storeType.StoreTypeNameBase == "datetime" ||
- storeType.StoreTypeNameBase == "timestamp") &&
- (valueGenerationStrategy == MySQLValueGenerationStrategy.IdentityColumn ||
- valueGenerationStrategy == MySQLValueGenerationStrategy.ComputedColumn) ||
- storeType.StoreTypeNameBase.Contains("text") ||
- storeType.StoreTypeNameBase.Contains("blob") ||
- storeType.StoreTypeNameBase == "geometry" ||
- storeType.StoreTypeNameBase == "json";
+ (storeType.StoreTypeNameBase == "datetime" ||
+ storeType.StoreTypeNameBase == "timestamp") &&
+ (valueGenerationStrategy == MySQLValueGenerationStrategy.IdentityColumn ||
+ valueGenerationStrategy == MySQLValueGenerationStrategy.ComputedColumn) ||
+ storeType.StoreTypeNameBase.Contains("text") ||
+ storeType.StoreTypeNameBase.Contains("blob") ||
+ storeType.StoreTypeNameBase == "geometry" ||
+ storeType.StoreTypeNameBase == "json";
}
return base.Add(target, diffContext, inline);
}
-#elif NET7_0 || NET8_0
+#elif NET9_0_OR_GREATER
public MySQLMigrationsModelDiffer(
- [NotNull] IRelationalTypeMappingSource typeMappingSource,
- [NotNull] IMigrationsAnnotationProvider migrationsAnnotations,
- [NotNull] IRowIdentityMapFactory rowIdentityMapFactory,
- [NotNull] CommandBatchPreparerDependencies commandBatchPreparerDependencies)
- : base(
- typeMappingSource,
- migrationsAnnotations,
- rowIdentityMapFactory,
- commandBatchPreparerDependencies)
+ [NotNull] IRelationalTypeMappingSource typeMappingSource,
+ [NotNull] IMigrationsAnnotationProvider migrationsAnnotations,
+ [NotNull] IRelationalAnnotationProvider relationalAnnotationProvider,
+ [NotNull] IRowIdentityMapFactory rowIdentityMapFactory,
+ [NotNull] CommandBatchPreparerDependencies commandBatchPreparerDependencies)
+ : base(
+ typeMappingSource,
+ migrationsAnnotations,
+ relationalAnnotationProvider,
+ rowIdentityMapFactory,
+ commandBatchPreparerDependencies)
{
}
@@ -115,8 +115,9 @@ protected override IEnumerable Add(IColumn target, DiffConte
}
return base.Add(target, diffContext, inline);
}
+
#endif
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Migrations/Internal/MySQLMigrator.cs b/EFCore/src/Migrations/Internal/MySQLMigrator.cs
index b4d944664..416ba9ef5 100644
--- a/EFCore/src/Migrations/Internal/MySQLMigrator.cs
+++ b/EFCore/src/Migrations/Internal/MySQLMigrator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -28,7 +28,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Internal;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
@@ -36,11 +38,683 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Transactions;
namespace MySql.EntityFrameworkCore.Migrations.Internal
{
+#if NET9_0_OR_GREATER
+ public class MySQLMigrator : IMigrator
+ {
+ private readonly IMigrationsAssembly _migrationsAssembly;
+ private readonly IHistoryRepository _historyRepository;
+ private readonly IRelationalDatabaseCreator _databaseCreator;
+ private readonly IMigrationsSqlGenerator _migrationsSqlGenerator;
+ private readonly IRawSqlCommandBuilder _rawSqlCommandBuilder;
+ private readonly IMigrationCommandExecutor _migrationCommandExecutor;
+ private readonly IRelationalConnection _connection;
+ private readonly ISqlGenerationHelper _sqlGenerationHelper;
+ private readonly ICurrentDbContext _currentContext;
+ private readonly IModelRuntimeInitializer _modelRuntimeInitializer;
+ private readonly IDiagnosticsLogger _logger;
+ private readonly IRelationalCommandDiagnosticsLogger _commandLogger;
+ private readonly IMigrationsModelDiffer _migrationsModelDiffer;
+ private readonly IDesignTimeModel _designTimeModel;
+ private readonly string _activeProvider;
+ private readonly IDbContextOptions _dbContextOptions;
+ private readonly IExecutionStrategy _executionStrategy;
+
+ public MySQLMigrator(
+ IMigrationsAssembly migrationsAssembly,
+ IHistoryRepository historyRepository,
+ IDatabaseCreator databaseCreator,
+ IMigrationsSqlGenerator migrationsSqlGenerator,
+ IRawSqlCommandBuilder rawSqlCommandBuilder,
+ IMigrationCommandExecutor migrationCommandExecutor,
+ IRelationalConnection connection,
+ ISqlGenerationHelper sqlGenerationHelper,
+ ICurrentDbContext currentContext,
+ IModelRuntimeInitializer modelRuntimeInitializer,
+ IDiagnosticsLogger logger,
+ IRelationalCommandDiagnosticsLogger commandLogger,
+ IDatabaseProvider databaseProvider,
+ IMigrationsModelDiffer migrationsModelDiffer,
+ IDesignTimeModel designTimeModel,
+ IDbContextOptions dbContextOptions,
+ IExecutionStrategy executionStrategy)
+ {
+ _migrationsAssembly = migrationsAssembly;
+ _historyRepository = historyRepository;
+ _databaseCreator = (IRelationalDatabaseCreator)databaseCreator;
+ _migrationsSqlGenerator = migrationsSqlGenerator;
+ _rawSqlCommandBuilder = rawSqlCommandBuilder;
+ _migrationCommandExecutor = migrationCommandExecutor;
+ _connection = connection;
+ _sqlGenerationHelper = sqlGenerationHelper;
+ _currentContext = currentContext;
+ _modelRuntimeInitializer = modelRuntimeInitializer;
+ _logger = logger;
+ _commandLogger = commandLogger;
+ _migrationsModelDiffer = migrationsModelDiffer;
+ _designTimeModel = designTimeModel;
+ _activeProvider = databaseProvider.Name;
+ _dbContextOptions = dbContextOptions;
+ _executionStrategy = executionStrategy;
+ }
+
+ protected virtual System.Data.IsolationLevel? MigrationTransactionIsolationLevel => null;
+
+ public virtual void Migrate(string? targetMigration)
+ {
+ var useTransaction = _connection.CurrentTransaction is null;
+ if (!useTransaction
+ && _executionStrategy.RetriesOnFailure)
+ {
+ throw new NotSupportedException(RelationalStrings.TransactionSuppressedMigrationInUserTransaction);
+ }
+
+ if (RelationalResources.LogPendingModelChanges(_logger).WarningBehavior != WarningBehavior.Ignore
+ && HasPendingModelChanges())
+ {
+ _logger.PendingModelChangesWarning(_currentContext.Context.GetType());
+ }
+
+ if (!useTransaction)
+ {
+ _logger.MigrationsUserTransactionWarning();
+ }
+
+ _logger.MigrateUsingConnection(this, _connection);
+
+ using var transactionScope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled);
+
+ if (!_databaseCreator.Exists())
+ {
+ _databaseCreator.Create();
+ }
+
+ _connection.Open();
+ try
+ {
+ var state = new MigrationExecutionState();
+ if (_historyRepository.LockReleaseBehavior != LockReleaseBehavior.Transaction
+ && useTransaction)
+ {
+ state.DatabaseLock = _historyRepository.AcquireDatabaseLock();
+ }
+
+ _executionStrategy.Execute(
+ this,
+ static (_, migrator) =>
+ {
+ migrator._connection.Open();
+ try
+ {
+ return migrator._historyRepository.CreateIfNotExists();
+ }
+ finally
+ {
+ migrator._connection.Close();
+ }
+ },
+ verifySucceeded: null);
+
+ _executionStrategy.Execute(
+ (Migrator: this,
+ TargetMigration: targetMigration,
+ State: state,
+ UseTransaction: useTransaction),
+ static (c, s) => s.Migrator.MigrateImplementation(c, s.TargetMigration, s.State, s.UseTransaction),
+ static (_, s) => new ExecutionResult(
+ successful: s.Migrator.VerifyMigrationSucceeded(s.TargetMigration, s.State),
+ result: true));
+ }
+ finally
+ {
+ _connection.Close();
+ }
+ }
+
+ private bool MigrateImplementation(DbContext context, string? targetMigration, MigrationExecutionState state, bool useTransaction)
+ {
+ var connectionOpened = _connection.Open();
+ try
+ {
+ if (useTransaction)
+ {
+ state.Transaction = MigrationTransactionIsolationLevel == null
+ ? _connection.BeginTransaction()
+ : _connection.BeginTransaction(MigrationTransactionIsolationLevel.Value);
+
+ state.DatabaseLock = state.DatabaseLock == null
+ ? _historyRepository.AcquireDatabaseLock()
+ : state.DatabaseLock.ReacquireIfNeeded(connectionOpened, useTransaction);
+ }
+
+ PopulateMigrations(
+ _historyRepository.GetAppliedMigrations().Select(t => t.MigrationId),
+ targetMigration,
+ out var migratorData);
+
+ var commandLists = GetMigrationCommandLists(migratorData);
+ foreach (var commandList in commandLists)
+ {
+ var (id, getCommands) = commandList;
+ if (id != state.CurrentMigrationId)
+ {
+ state.CurrentMigrationId = id;
+ state.LastCommittedCommandIndex = 0;
+ }
+
+ _migrationCommandExecutor.ExecuteNonQuery(getCommands(), _connection, state, commitTransaction: false, MigrationTransactionIsolationLevel);
+ }
+
+ var coreOptionsExtension =
+ _dbContextOptions.FindExtension()
+ ?? new CoreOptionsExtension();
+
+ var seed = coreOptionsExtension.Seeder;
+ if (seed != null)
+ {
+ seed(context, state.AnyOperationPerformed);
+ }
+ else if (coreOptionsExtension.AsyncSeeder != null)
+ {
+ throw new InvalidOperationException(CoreStrings.MissingSeeder);
+ }
+
+ state.Transaction?.Commit();
+ return state.AnyOperationPerformed;
+ }
+ finally
+ {
+ state.DatabaseLock?.Dispose();
+ state.DatabaseLock = null;
+ state.Transaction?.Dispose();
+ state.Transaction = null;
+ _connection.Close();
+ }
+ }
+
+ public virtual async Task MigrateAsync(
+ string? targetMigration,
+ CancellationToken cancellationToken = default)
+ {
+ var useTransaction = _connection.CurrentTransaction is null;
+ if (!useTransaction
+ && _executionStrategy.RetriesOnFailure)
+ {
+ throw new NotSupportedException(RelationalStrings.TransactionSuppressedMigrationInUserTransaction);
+ }
+
+ if (RelationalResources.LogPendingModelChanges(_logger).WarningBehavior != WarningBehavior.Ignore
+ && HasPendingModelChanges())
+ {
+ _logger.PendingModelChangesWarning(_currentContext.Context.GetType());
+ }
+
+ if (!useTransaction)
+ {
+ _logger.MigrationsUserTransactionWarning();
+ }
+
+ _logger.MigrateUsingConnection(this, _connection);
+
+ using var transactionScope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled);
+
+ if (!await _databaseCreator.ExistsAsync(cancellationToken).ConfigureAwait(false))
+ {
+ await _databaseCreator.CreateAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ await _connection.OpenAsync(cancellationToken).ConfigureAwait(false);
+ try
+ {
+ var state = new MigrationExecutionState();
+ if (_historyRepository.LockReleaseBehavior != LockReleaseBehavior.Transaction
+ && useTransaction)
+ {
+ state.DatabaseLock = await _historyRepository.AcquireDatabaseLockAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ await _executionStrategy.ExecuteAsync(
+ this,
+ static async (_, migrator, ct) =>
+ {
+ await migrator._connection.OpenAsync(ct).ConfigureAwait(false);
+ try
+ {
+ return await migrator._historyRepository.CreateIfNotExistsAsync(ct).ConfigureAwait(false);
+ }
+ finally
+ {
+ await migrator._connection.CloseAsync().ConfigureAwait(false);
+ }
+ },
+ verifySucceeded: null,
+ cancellationToken).ConfigureAwait(false);
+
+ await _executionStrategy.ExecuteAsync(
+ (Migrator: this,
+ TargetMigration: targetMigration,
+ State: state,
+ UseTransaction: useTransaction),
+ async static (c, s, ct) => await s.Migrator.MigrateImplementationAsync(
+ c, s.TargetMigration, s.State, s.UseTransaction, ct).ConfigureAwait(false),
+ async static (_, s, ct) => new ExecutionResult(
+ successful: await s.Migrator.VerifyMigrationSucceededAsync(s.TargetMigration, s.State, ct).ConfigureAwait(false),
+ result: true),
+ cancellationToken)
+ .ConfigureAwait(false);
+ }
+ finally
+ {
+ await _connection.CloseAsync().ConfigureAwait(false);
+ }
+ }
+
+ private async Task MigrateImplementationAsync(
+ DbContext context, string? targetMigration, MigrationExecutionState state, bool useTransaction, CancellationToken cancellationToken = default)
+ {
+ var connectionOpened = await _connection.OpenAsync(cancellationToken).ConfigureAwait(false);
+ try
+ {
+ if (useTransaction)
+ {
+ state.Transaction = await (MigrationTransactionIsolationLevel == null
+ ? context.Database.BeginTransactionAsync(cancellationToken)
+ : context.Database.BeginTransactionAsync(MigrationTransactionIsolationLevel.Value, cancellationToken))
+ .ConfigureAwait(false);
+
+ state.DatabaseLock = state.DatabaseLock == null
+ ? await _historyRepository.AcquireDatabaseLockAsync(cancellationToken).ConfigureAwait(false)
+ : await state.DatabaseLock.ReacquireIfNeededAsync(connectionOpened, useTransaction, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ PopulateMigrations(
+ (await _historyRepository.GetAppliedMigrationsAsync(cancellationToken).ConfigureAwait(false)).Select(t => t.MigrationId),
+ targetMigration,
+ out var migratorData);
+
+ var commandLists = GetMigrationCommandLists(migratorData);
+ foreach (var commandList in commandLists)
+ {
+ var (id, getCommands) = commandList;
+ if (id != state.CurrentMigrationId)
+ {
+ state.CurrentMigrationId = id;
+ state.LastCommittedCommandIndex = 0;
+ }
+
+ await _migrationCommandExecutor.ExecuteNonQueryAsync(
+ getCommands(), _connection, state, commitTransaction: false, MigrationTransactionIsolationLevel, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
+ var coreOptionsExtension =
+ _dbContextOptions.FindExtension()
+ ?? new CoreOptionsExtension();
+
+ var seedAsync = coreOptionsExtension.AsyncSeeder;
+ if (seedAsync != null)
+ {
+ await seedAsync(context, state.AnyOperationPerformed, cancellationToken).ConfigureAwait(false);
+ }
+ else if (coreOptionsExtension.Seeder != null)
+ {
+ throw new InvalidOperationException(CoreStrings.MissingSeeder);
+ }
+
+ if (state.Transaction != null)
+ {
+ await state.Transaction.CommitAsync(cancellationToken).ConfigureAwait(false);
+ }
+ return state.AnyOperationPerformed;
+ }
+ finally
+ {
+ if (state.DatabaseLock != null)
+ {
+ state.DatabaseLock.Dispose();
+ state.DatabaseLock = null;
+ }
+ if (state.Transaction != null)
+ {
+ await state.Transaction.DisposeAsync().ConfigureAwait(false);
+ state.Transaction = null;
+ }
+ await _connection.CloseAsync().ConfigureAwait(false);
+ }
+ }
+
+ private IEnumerable<(string, Func>)> GetMigrationCommandLists(MigratorData parameters)
+ {
+ var migrationsToApply = parameters.AppliedMigrations;
+ var migrationsToRevert = parameters.RevertedMigrations;
+ var actualTargetMigration = parameters.TargetMigration;
+
+ for (var i = 0; i < migrationsToRevert.Count; i++)
+ {
+ var migration = migrationsToRevert[i];
+
+ var index = i;
+ yield return (migration.GetId(), () =>
+ {
+ _logger.MigrationReverting(this, migration);
+
+ var commands = GenerateDownSql(
+ migration,
+ index != migrationsToRevert.Count - 1
+ ? migrationsToRevert[index + 1]
+ : actualTargetMigration);
+ if (migration.DownOperations.Count > 1
+ && commands.FirstOrDefault(c => c.TransactionSuppressed) is MigrationCommand nonTransactionalCommand)
+ {
+ _logger.NonTransactionalMigrationOperationWarning(this, migration, nonTransactionalCommand);
+ }
+
+ return commands;
+ }
+ );
+ }
+
+ foreach (var migration in migrationsToApply)
+ {
+ yield return (migration.GetId(), () =>
+ {
+ _logger.MigrationApplying(this, migration);
+
+ var commands = GenerateUpSql(migration);
+ if (migration.UpOperations.Count > 1
+ && commands.FirstOrDefault(c => c.TransactionSuppressed) is MigrationCommand nonTransactionalCommand)
+ {
+ _logger.NonTransactionalMigrationOperationWarning(this, migration, nonTransactionalCommand);
+ }
+
+ return commands;
+ }
+ );
+ }
+
+ if (migrationsToRevert.Count + migrationsToApply.Count == 0)
+ {
+ _logger.MigrationsNotApplied(this);
+ }
+ }
+
+ protected virtual void PopulateMigrations(
+ IEnumerable appliedMigrationEntries,
+ string? targetMigration,
+ out MigratorData parameters)
+ {
+ var appliedMigrations = new Dictionary();
+ var unappliedMigrations = new Dictionary();
+ var appliedMigrationEntrySet = new HashSet(appliedMigrationEntries, StringComparer.OrdinalIgnoreCase);
+ if (_migrationsAssembly.Migrations.Count == 0)
+ {
+ _logger.MigrationsNotFound(this, _migrationsAssembly);
+ }
+
+ foreach (var (key, typeInfo) in _migrationsAssembly.Migrations)
+ {
+ if (appliedMigrationEntrySet.Contains(key))
+ {
+ appliedMigrations.Add(key, typeInfo);
+ }
+ else
+ {
+ unappliedMigrations.Add(key, typeInfo);
+ }
+ }
+
+ IReadOnlyList migrationsToApply;
+ IReadOnlyList migrationsToRevert;
+ Migration? actualTargetMigration = null;
+ if (string.IsNullOrEmpty(targetMigration))
+ {
+ migrationsToApply = unappliedMigrations
+ .OrderBy(m => m.Key)
+ .Select(p => _migrationsAssembly.CreateMigration(p.Value, _activeProvider))
+ .ToList();
+ migrationsToRevert = [];
+ }
+ else if (targetMigration == Migration.InitialDatabase)
+ {
+ migrationsToApply = [];
+ migrationsToRevert = appliedMigrations
+ .OrderByDescending(m => m.Key)
+ .Select(p => _migrationsAssembly.CreateMigration(p.Value, _activeProvider))
+ .ToList();
+ }
+ else
+ {
+ targetMigration = _migrationsAssembly.GetMigrationId(targetMigration);
+ migrationsToApply = unappliedMigrations
+ .Where(m => string.Compare(m.Key, targetMigration, StringComparison.OrdinalIgnoreCase) <= 0)
+ .OrderBy(m => m.Key)
+ .Select(p => _migrationsAssembly.CreateMigration(p.Value, _activeProvider))
+ .ToList();
+ migrationsToRevert = appliedMigrations
+ .Where(m => string.Compare(m.Key, targetMigration, StringComparison.OrdinalIgnoreCase) > 0)
+ .OrderByDescending(m => m.Key)
+ .Select(p => _migrationsAssembly.CreateMigration(p.Value, _activeProvider))
+ .ToList();
+ actualTargetMigration = appliedMigrations
+ .Where(m => string.Compare(m.Key, targetMigration, StringComparison.OrdinalIgnoreCase) == 0)
+ .Select(p => _migrationsAssembly.CreateMigration(p.Value, _activeProvider))
+ .SingleOrDefault();
+ }
+
+ parameters = new MigratorData(migrationsToApply, migrationsToRevert, actualTargetMigration);
+ }
+
+ protected virtual bool VerifyMigrationSucceeded(
+ string? targetMigration, MigrationExecutionState state)
+ => false;
+
+ protected virtual Task VerifyMigrationSucceededAsync(
+ string? targetMigration, MigrationExecutionState state, CancellationToken cancellationToken)
+ => Task.FromResult(false);
+
+ public virtual string GenerateScript(
+ string? fromMigration = null,
+ string? toMigration = null,
+ MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)
+ {
+ options |= MigrationsSqlGenerationOptions.Script;
+
+ var idempotent = options.HasFlag(MigrationsSqlGenerationOptions.Idempotent);
+ var noTransactions = options.HasFlag(MigrationsSqlGenerationOptions.NoTransactions);
+
+ IEnumerable appliedMigrations;
+ if (string.IsNullOrEmpty(fromMigration)
+ || fromMigration == Migration.InitialDatabase)
+ {
+ appliedMigrations = Enumerable.Empty();
+ }
+ else
+ {
+ var fromMigrationId = _migrationsAssembly.GetMigrationId(fromMigration);
+ appliedMigrations = _migrationsAssembly.Migrations
+ .Where(t => string.Compare(t.Key, fromMigrationId, StringComparison.OrdinalIgnoreCase) <= 0)
+ .Select(t => t.Key);
+ }
+
+ PopulateMigrations(appliedMigrations, toMigration, out var migratorData);
+
+ var builder = new IndentedStringBuilder();
+
+ if (fromMigration == Migration.InitialDatabase
+ || string.IsNullOrEmpty(fromMigration))
+ {
+ builder
+ .Append(_historyRepository.GetCreateIfNotExistsScript())
+ .Append(_sqlGenerationHelper.BatchTerminator);
+ }
+
+ var idempotencyEnd = idempotent
+ ? _historyRepository.GetEndIfScript()
+ : null;
+ var migrationsToApply = migratorData.AppliedMigrations;
+ var migrationsToRevert = migratorData.RevertedMigrations;
+ var actualTargetMigration = migratorData.TargetMigration;
+ var transactionStarted = false;
+ for (var i = 0; i < migrationsToRevert.Count; i++)
+ {
+ var migration = migrationsToRevert[i];
+ var previousMigration = i != migrationsToRevert.Count - 1
+ ? migrationsToRevert[i + 1]
+ : actualTargetMigration;
+
+ _logger.MigrationGeneratingDownScript(this, migration, fromMigration, toMigration, idempotent);
+
+ var idempotencyCondition = idempotent
+ ? _historyRepository.GetBeginIfExistsScript(migration.GetId())
+ : null;
+
+ GenerateSqlScript(
+ GenerateDownSql(migration, previousMigration, options),
+ builder, _sqlGenerationHelper, ref transactionStarted, noTransactions, idempotencyCondition, idempotencyEnd);
+ }
+
+ foreach (var migration in migrationsToApply)
+ {
+ _logger.MigrationGeneratingUpScript(this, migration, fromMigration, toMigration, idempotent);
+
+ var idempotencyCondition = idempotent
+ ? _historyRepository.GetBeginIfNotExistsScript(migration.GetId())
+ : null;
+
+ GenerateSqlScript(
+ GenerateUpSql(migration, options),
+ builder, _sqlGenerationHelper, ref transactionStarted, noTransactions, idempotencyCondition, idempotencyEnd);
+ }
+
+ if (transactionStarted)
+ {
+ builder
+ .AppendLine(_sqlGenerationHelper.CommitTransactionStatement)
+ .Append(_sqlGenerationHelper.BatchTerminator);
+ }
+
+ return builder.ToString();
+ }
+
+ private static void GenerateSqlScript(
+ IEnumerable commands,
+ IndentedStringBuilder builder,
+ ISqlGenerationHelper sqlGenerationHelper,
+ ref bool transactionStarted,
+ bool noTransactions = false,
+ string? idempotencyCondition = null,
+ string? idempotencyEnd = null)
+ {
+ foreach (var command in commands)
+ {
+ if (!noTransactions)
+ {
+ if (!transactionStarted && !command.TransactionSuppressed)
+ {
+ builder
+ .AppendLine(sqlGenerationHelper.StartTransactionStatement);
+ transactionStarted = true;
+ }
+
+ if (transactionStarted && command.TransactionSuppressed)
+ {
+ builder
+ .AppendLine(sqlGenerationHelper.CommitTransactionStatement)
+ .Append(sqlGenerationHelper.BatchTerminator);
+ transactionStarted = false;
+ }
+ }
+
+ if (idempotencyCondition != null
+ && idempotencyEnd != null)
+ {
+ builder.AppendLine(idempotencyCondition);
+ using (builder.Indent())
+ {
+ builder.AppendLines(command.CommandText);
+ }
+
+ builder.Append(idempotencyEnd);
+ }
+ else
+ {
+ builder.Append(command.CommandText);
+ }
+
+ if (!transactionStarted)
+ {
+ builder.Append(sqlGenerationHelper.BatchTerminator);
+ }
+ else
+ {
+ builder.Append(Environment.NewLine);
+ }
+ }
+ }
+
+ protected virtual IReadOnlyList GenerateUpSql(
+ Migration migration,
+ MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)
+ {
+ var insertCommand = _rawSqlCommandBuilder.Build(
+ _historyRepository.GetInsertScript(new HistoryRow(migration.GetId(), ProductInfo.GetVersion())));
+
+ var operations = _migrationsSqlGenerator
+ .Generate(
+ migration.UpOperations,
+ FinalizeModel(migration.TargetModel),
+ options);
+
+ return
+ [
+ .. operations,
+ new MigrationCommand(insertCommand, _currentContext.Context, _commandLogger,
+ transactionSuppressed: operations.Any(o => o.TransactionSuppressed)),
+ ];
+ }
+
+ protected virtual IReadOnlyList GenerateDownSql(
+ Migration migration,
+ Migration? previousMigration,
+ MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)
+ {
+ var deleteCommand = _rawSqlCommandBuilder.Build(
+ _historyRepository.GetDeleteScript(migration.GetId()));
+
+ var operations = _migrationsSqlGenerator
+ .Generate(
+ migration.DownOperations,
+ previousMigration == null ? null : FinalizeModel(previousMigration.TargetModel),
+ options);
+
+ return [
+ .. operations,
+ new MigrationCommand(deleteCommand, _currentContext.Context, _commandLogger,
+ transactionSuppressed: operations.Any(o => o.TransactionSuppressed))
+ ];
+ }
+
+ private IModel? FinalizeModel(IModel? model)
+ => model == null
+ ? null
+ : _modelRuntimeInitializer.Initialize(model);
+
+ public bool HasPendingModelChanges()
+ => _migrationsModelDiffer.HasDifferences(
+ FinalizeModel(_migrationsAssembly.ModelSnapshot?.Model)?.GetRelationalModel(),
+ _designTimeModel.Model.GetRelationalModel());
+ }
+#else
+
internal class MySQLMigrator : Migrator
{
private static readonly Dictionary> _customMigrationCommands =
@@ -350,4 +1024,5 @@ INTO PRIMARY_KEY_COLUMN_NAME
#endregion Custom SQL
}
+#endif
}
diff --git a/EFCore/src/Migrations/MySQLMigrationsSqlGenerator.cs b/EFCore/src/Migrations/MySQLMigrationsSqlGenerator.cs
index 32a7491a5..e8e73db2f 100644
--- a/EFCore/src/Migrations/MySQLMigrationsSqlGenerator.cs
+++ b/EFCore/src/Migrations/MySQLMigrationsSqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -128,7 +128,7 @@ protected override void Generate(RenameColumnOperation operation, IModel? model,
var typeMapping = column.PropertyMappings.FirstOrDefault()?.TypeMapping;
var converter = typeMapping?.Converter;
- var clrType = (converter!.ProviderClrType ?? typeMapping!.ClrType).UnwrapNullableType();
+ var clrType = (converter?.ProviderClrType ?? typeMapping!.ClrType).UnwrapNullableType();
var columnType = (string)(operation[RelationalAnnotationNames.ColumnType]
?? column[RelationalAnnotationNames.ColumnType])!;
var isNullable = column.IsNullable;
@@ -537,7 +537,12 @@ protected override void Generate(
if (model?.GetRelationalModel().FindTable(operation.Name, operation.Schema) != null)
{
+#if !NET8_0_OR_GREATER
var entity = model?.GetRelationalModel().FindTable(operation.Name, operation.Schema)!.EntityTypeMappings.FirstOrDefault()!.EntityType;
+#else
+ var entity = model?.GetRelationalModel().FindTable(operation.Name, operation.Schema)!.EntityTypeMappings.FirstOrDefault()!.TypeBase;
+#endif
+
var charset = entity?.FindAnnotation(MySQLAnnotationNames.Charset);
if (charset != null)
{
diff --git a/EFCore/src/Migrations/Operations/CreateDatabaseOperation.cs b/EFCore/src/Migrations/Operations/CreateDatabaseOperation.cs
index 6e0a422af..1e266a2ff 100644
--- a/EFCore/src/Migrations/Operations/CreateDatabaseOperation.cs
+++ b/EFCore/src/Migrations/Operations/CreateDatabaseOperation.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Migrations/Operations/DropDatabaseOperation.cs b/EFCore/src/Migrations/Operations/DropDatabaseOperation.cs
index 3e1df9d00..bb9dc3bf0 100644
--- a/EFCore/src/Migrations/Operations/DropDatabaseOperation.cs
+++ b/EFCore/src/Migrations/Operations/DropDatabaseOperation.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -40,4 +40,4 @@ internal class MySQLDropDatabaseOperation : MigrationOperation
///
public virtual string Name { get; set; } = null!;
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Migrations/Operations/MySQLDropPrimaryKeyAndRecreateForeignKeysOperation.cs b/EFCore/src/Migrations/Operations/MySQLDropPrimaryKeyAndRecreateForeignKeysOperation.cs
index 68fcf8a10..1626aff58 100644
--- a/EFCore/src/Migrations/Operations/MySQLDropPrimaryKeyAndRecreateForeignKeysOperation.cs
+++ b/EFCore/src/Migrations/Operations/MySQLDropPrimaryKeyAndRecreateForeignKeysOperation.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Migrations/Operations/MySQLDropUniqueConstraintAndRecreateForeignKeysOperation.cs b/EFCore/src/Migrations/Operations/MySQLDropUniqueConstraintAndRecreateForeignKeysOperation.cs
index 574d77ae6..005a01f4b 100644
--- a/EFCore/src/Migrations/Operations/MySQLDropUniqueConstraintAndRecreateForeignKeysOperation.cs
+++ b/EFCore/src/Migrations/Operations/MySQLDropUniqueConstraintAndRecreateForeignKeysOperation.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/MySql.EntityFrameworkCore.csproj b/EFCore/src/MySql.EntityFrameworkCore.csproj
index 379b4289a..8a96c4f35 100644
--- a/EFCore/src/MySql.EntityFrameworkCore.csproj
+++ b/EFCore/src/MySql.EntityFrameworkCore.csproj
@@ -7,10 +7,10 @@
MySql;.NET Connector;MySql Entity Framework Core;netcore;.Net Core;MySql Conector/Net Entity Framework Core;coreclr;C/NET;C/Net Core
http://www.mysql.com/common/logos/logo-mysql-170x115.png
https://github.com/mysql/mysql-connector-net
- GPL-2.0-only
+ GPL-2.0-only WITH Universal-FOSS-exception-1.0
true
- 10.0
- net6.0;net7.0;net8.0;
+ 13.0
+ net9.0;net8.0;
MySql.EntityFrameworkCore
MySql.EntityFrameworkCore
enable
@@ -18,22 +18,27 @@
True
..\..\ConnectorNetPublicKey.snk
true
- $(NoWarn);CS1591;EF1001
+ $(NoWarn);CS1591;EF1001;EF9100
+ false
-
-
-
-
+
+ $(TargetFrameworks);net10.0
+
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
diff --git a/EFCore/src/Properties/AssemblyInfo.cs b/EFCore/src/Properties/AssemblyInfo.cs
index b9717d9db..48eeec93c 100644
--- a/EFCore/src/Properties/AssemblyInfo.cs
+++ b/EFCore/src/Properties/AssemblyInfo.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -27,8 +27,25 @@
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
using Microsoft.EntityFrameworkCore.Design;
+using System.Reflection;
+using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Security;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MySql.EntityFrameworkCore")]
+[assembly: AssemblyDescription("MySql.EntityFrameworkCore adds support for Microsoft Entity Framework Core (EF Core) 8 and 9.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Oracle Corporation")]
+[assembly: AssemblyProduct("MySQL Connector/NET")]
+[assembly: AssemblyCopyright("Copyright © 2021, 2025, Oracle and/or its affiliates.")]
+[assembly: AssemblyTrademark("Oracle®, Java, MySQL, and NetSuite are registered trademarks of Oracle and/or its affiliates.")]
+[assembly: AssemblyCulture("")]
+[assembly: SecurityRules(SecurityRuleSet.Level1)]
+[assembly: CLSCompliant(false)]
// Setting ComVisible to false makes the types in this assembly not visible to COM
// components. If you need to access a type in this assembly from COM, set the ComVisible
@@ -43,4 +60,4 @@
[assembly: InternalsVisibleTo("MySql.EntityFrameworkCore.Basic.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1")]
[assembly: InternalsVisibleTo("MySql.EntityFrameworkCore.Design.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1")]
[assembly: InternalsVisibleTo("MySql.EntityFrameworkCore.Migrations.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1")]
-[assembly: DesignTimeProviderServices("MySql.EntityFrameworkCore.Design.Internal.MySQLDesignTimeServices")]
\ No newline at end of file
+[assembly: DesignTimeProviderServices("MySql.EntityFrameworkCore.Design.Internal.MySQLDesignTimeServices")]
diff --git a/EFCore/src/Properties/VersionInfo.cs b/EFCore/src/Properties/VersionInfo.cs
new file mode 100644
index 000000000..2613c8c80
--- /dev/null
+++ b/EFCore/src/Properties/VersionInfo.cs
@@ -0,0 +1,58 @@
+// Copyright © 2024, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Reflection;
+using System.Resources;
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+#if NET8_0
+[assembly: AssemblyVersion("9.4.0")]
+[assembly: AssemblyInformationalVersion("8.0.11.0+MySQL9.4.0")]
+[assembly: AssemblyFileVersion("9.4.0.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
+#elif NET9_0
+[assembly: AssemblyVersion("9.4.0")]
+[assembly: AssemblyInformationalVersion("9.0.3.0+MySQL9.4.0")]
+[assembly: AssemblyFileVersion("9.4.0.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
+#elif NET10_0
+[assembly: AssemblyVersion("9.4.0")]
+[assembly: AssemblyInformationalVersion("10.0.0.0-preview+MySQL9.4.0")]
+[assembly: AssemblyFileVersion("9.4.0.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
+#endif
diff --git a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLByteArrayMethodTranslator.cs b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLByteArrayMethodTranslator.cs
index e331121ca..61466321f 100644
--- a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLByteArrayMethodTranslator.cs
+++ b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLByteArrayMethodTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLDbFunctionsExtensionsMethodTranslator.cs b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLDbFunctionsExtensionsMethodTranslator.cs
index 9c477b19f..82688e6cf 100644
--- a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLDbFunctionsExtensionsMethodTranslator.cs
+++ b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLDbFunctionsExtensionsMethodTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLRegexIsMatchTranslator.cs b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLRegexIsMatchTranslator.cs
index 5b027f243..bda2f2990 100644
--- a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLRegexIsMatchTranslator.cs
+++ b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLRegexIsMatchTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLStringLengthTranslator.cs b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLStringLengthTranslator.cs
index 18b445d2d..64d23c763 100644
--- a/EFCore/src/Query/ExpressionTranslators/Internal/MySQLStringLengthTranslator.cs
+++ b/EFCore/src/Query/ExpressionTranslators/Internal/MySQLStringLengthTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -66,4 +66,4 @@ public SqlExpression Translate(SqlExpression? instance, MemberInfo member, Type
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLBinaryExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLBinaryExpression.cs
index ccf5d69f2..9a3e30f10 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLBinaryExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLBinaryExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -32,6 +32,7 @@
using MySql.EntityFrameworkCore.Utils;
using System;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
@@ -60,6 +61,9 @@ public MySQLBinaryExpression(
Right = right;
}
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
public virtual MySQLBinaryExpressionOperatorType OperatorType { get; }
public virtual SqlExpression Left { get; }
public virtual SqlExpression Right { get; }
@@ -77,6 +81,18 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
return Update(left, right);
}
+#if NET9_0_OR_GREATER
+ ///
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLBinaryExpression).GetConstructor(
+ [typeof(ExpressionType), typeof(SqlExpression), typeof(SqlExpression), typeof(Type), typeof(RelationalTypeMapping)])!,
+ Constant(OperatorType),
+ Left.Quote(),
+ Right.Quote(),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLBinaryExpression Update(SqlExpression left, SqlExpression right)
=> left != Left || right != Right
? new MySQLBinaryExpression(OperatorType, left, right, Type, TypeMapping)
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLCollateExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLCollateExpression.cs
index eac7aed15..123249735 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLCollateExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLCollateExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -32,6 +32,7 @@
using System;
using System.Linq;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
@@ -44,17 +45,31 @@ internal class MySQLCollateExpression : SqlExpression
private readonly string _charset;
private readonly string _collation;
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
+#if NET9_0_OR_GREATER
+ public MySQLCollateExpression(SqlExpression operand, string collation)
+ : base(operand.Type, operand.TypeMapping)
+ {
+ Operand = operand;
+ Collation = collation;
+ }
+#else
public MySQLCollateExpression(
- SqlExpression valueExpression,
- string charset,
- string collation,
- RelationalTypeMapping? typeMapping)
- : base(typeof(string), typeMapping)
+ SqlExpression valueExpression,
+ string charset,
+ string collation,
+ RelationalTypeMapping? typeMapping)
+ : base(typeof(string), typeMapping)
{
_valueExpression = valueExpression;
_charset = charset;
_collation = collation;
}
+#endif
+
///
/// The expression for which a collation is being specified.
@@ -66,10 +81,21 @@ public MySQLCollateExpression(
///
public virtual string Charset => _charset;
+#if NET9_0_OR_GREATER
+ ///
+ /// The expression on which collation is applied.
+ ///
+ public virtual SqlExpression Operand { get; }
+
+ public virtual string Collation { get; }
+#else
///
/// The collation that the string is being converted to.
///
public virtual string Collation => _collation;
+#endif
+
+
///
/// Dispatches to the specific visit method for this node type.
@@ -100,11 +126,24 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
}
+#if NET9_0_OR_GREATER
+ public virtual MySQLCollateExpression Update(SqlExpression operand)
+ => operand != Operand
+ ? new MySQLCollateExpression(operand, Collation)
+ : this;
+ ///
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLCollateExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Operand.Quote(),
+ Constant(Collation));
+
+#else
public virtual MySQLCollateExpression Update(SqlExpression valueExpression)
=> valueExpression != _valueExpression &&
valueExpression != null
? new MySQLCollateExpression(valueExpression, _charset, _collation, TypeMapping)
: this;
+#endif
///
/// Tests if this object is considered equal to another.
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLColumnAliasReferenceExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLColumnAliasReferenceExpression.cs
index f78459e79..50cfadc82 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLColumnAliasReferenceExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLColumnAliasReferenceExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
@@ -39,6 +40,10 @@ namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
///
internal class MySQLColumnAliasReferenceExpression : SqlExpression, IEquatable
{
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
[NotNull]
public virtual string Alias { get; }
@@ -67,6 +72,15 @@ public virtual MySQLColumnAliasReferenceExpression Update(
? this
: new MySQLColumnAliasReferenceExpression(alias, expression, Type, TypeMapping!);
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLColumnAliasReferenceExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Constant(Alias),
+ Expression.Quote(),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public override bool Equals(object? obj)
=> Equals(obj as MySQLColumnAliasReferenceExpression);
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLComplexFunctionArgumentExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLComplexFunctionArgumentExpression.cs
index c15370204..2290f0b86 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLComplexFunctionArgumentExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLComplexFunctionArgumentExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -33,11 +33,17 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
internal class MySQLComplexFunctionArgumentExpression : SqlExpression
{
+
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
///
/// The arguments parts.
///
@@ -74,6 +80,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
return Update(argumentParts, Delimiter);
}
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLComplexFunctionArgumentExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Constant(ArgumentParts),
+ Constant(Delimiter),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLComplexFunctionArgumentExpression Update(IReadOnlyList argumentParts, string delimiter)
=> !argumentParts.SequenceEqual(ArgumentParts)
? new MySQLComplexFunctionArgumentExpression(argumentParts, delimiter, Type, TypeMapping!)
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLJsonArrayIndexExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLJsonArrayIndexExpression.cs
index ac6ad4501..a1f5f5ba2 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLJsonArrayIndexExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLJsonArrayIndexExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
@@ -39,6 +40,11 @@ namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
///
internal class MySQLJsonArrayIndexExpression : SqlExpression, IEquatable
{
+
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
[NotNull]
public virtual SqlExpression Expression { get; }
@@ -54,6 +60,14 @@ public MySQLJsonArrayIndexExpression(
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update((SqlExpression)visitor.Visit(Expression));
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLJsonArrayIndexExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Expression.Quote(),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLJsonArrayIndexExpression Update(
[NotNull] SqlExpression expression)
=> expression == Expression
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLJsonTraversalExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLJsonTraversalExpression.cs
index 2ad30e237..2b31cc35a 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLJsonTraversalExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLJsonTraversalExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
@@ -42,6 +43,10 @@ namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
///
internal class MySQLJsonTraversalExpression : SqlExpression, IEquatable
{
+
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
///
/// The JSON column.
///
@@ -91,6 +96,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update((SqlExpression)visitor.Visit(Expression),
Path.Select(p => (SqlExpression)visitor.Visit(p)).ToArray());
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLJsonTraversalExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Expression.Quote(),
+ Constant(ReturnsText),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLJsonTraversalExpression Update(
[NotNull] SqlExpression expression,
[NotNull] IReadOnlyList path)
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLMatchExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLMatchExpression.cs
index 5a3875b2c..6ada3a8d7 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLMatchExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLMatchExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -33,11 +33,17 @@
using MySql.EntityFrameworkCore.Utils;
using System;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
internal class MySQLMatchExpression : SqlExpression
{
+
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
public MySQLMatchExpression(
SqlExpression match,
SqlExpression against,
@@ -75,6 +81,16 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
return Update(match, against);
}
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLMatchExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Match.Quote(),
+ Against.Quote(),
+ Constant(SearchMode),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLMatchExpression Update(SqlExpression match, SqlExpression against)
=> match != Match || against != Against
? new MySQLMatchExpression(
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLRegexpExpression.cs b/EFCore/src/Query/Expressions/Internal/MySQLRegexpExpression.cs
index 6cb14eaeb..e0e19feb6 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLRegexpExpression.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLRegexpExpression.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,11 +31,17 @@
using Microsoft.EntityFrameworkCore.Storage;
using MySql.EntityFrameworkCore.Utils;
using System.Linq.Expressions;
+using System.Reflection;
namespace MySql.EntityFrameworkCore.Query.Expressions.Internal
{
internal class MySQLRegexpExpression : SqlExpression
{
+
+#if NET9_0_OR_GREATER
+ private static ConstructorInfo? _quotingConstructor;
+#endif
+
public MySQLRegexpExpression(
[NotNull] SqlExpression match,
[NotNull] SqlExpression pattern,
@@ -69,6 +75,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
return Update(match, pattern);
}
+#if NET9_0_OR_GREATER
+ public override Expression Quote() => New(
+ _quotingConstructor ??= typeof(MySQLMatchExpression).GetConstructor([typeof(SqlExpression), typeof(string)])!,
+ Match.Quote(),
+ Pattern.Quote(),
+ Constant(Type),
+ RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping));
+#endif
+
public virtual MySQLRegexpExpression Update(SqlExpression match, SqlExpression pattern)
=> match != Match ||
pattern != Pattern
diff --git a/EFCore/src/Query/Expressions/Internal/MySQLStringComparisonMethodTranslator.cs b/EFCore/src/Query/Expressions/Internal/MySQLStringComparisonMethodTranslator.cs
index a9427da6a..1af3ac2cb 100644
--- a/EFCore/src/Query/Expressions/Internal/MySQLStringComparisonMethodTranslator.cs
+++ b/EFCore/src/Query/Expressions/Internal/MySQLStringComparisonMethodTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using MySql.EntityFrameworkCore.Query.Internal;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
using System.Text;
using static MySql.EntityFrameworkCore.Utils.Statics;
@@ -165,6 +166,7 @@ public MySQLStringComparisonMethodTranslator(ISqlExpressionFactory sqlExpression
}
else
{
+#if !NET8_0_OR_GREATER
return new CaseExpression(
new[]
{
@@ -183,6 +185,26 @@ public MySQLStringComparisonMethodTranslator(ISqlExpressionFactory sqlExpression
Utf8Bin(LCase(rightValue))
)
);
+#else
+ return new CaseExpression(
+ new[]
+ {
+ new CaseWhenClause(
+ _sqlExpressionFactory.In(stringComparison,(IReadOnlyList)_caseSensitiveComparisons),
+ // Case sensitive, accent sensitive
+ _sqlExpressionFactory.Equal(
+ leftValue,
+ Utf8Bin(rightValue)
+ )
+ )
+ },
+ // Case insensitive, accent sensitive
+ _sqlExpressionFactory.Equal(
+ LCase(leftValue),
+ Utf8Bin(LCase(rightValue))
+ )
+ );
+#endif
}
}
@@ -210,6 +232,7 @@ public MySQLStringComparisonMethodTranslator(ISqlExpressionFactory sqlExpression
}
else
{
+#if !NET8_0_OR_GREATER
return new CaseExpression(
new[]
{
@@ -229,6 +252,27 @@ public MySQLStringComparisonMethodTranslator(ISqlExpressionFactory sqlExpression
Utf8Bin(LCase(prefix))
)
);
+#else
+ return new CaseExpression(
+ new[]
+ {
+ new CaseWhenClause(
+ _sqlExpressionFactory.In(stringComparison,(IReadOnlyList) _caseSensitiveComparisons),
+ // Case sensitive, accent sensitive
+ MakeStartsWithExpressionImpl(
+ target,
+ Utf8Bin(prefix),
+ originalPrefix: prefix
+ )
+ )
+ },
+ // Case insensitive, accent sensitive
+ MakeStartsWithExpressionImpl(
+ LCase(target),
+ Utf8Bin(LCase(prefix))
+ )
+ );
+#endif
}
}
@@ -237,7 +281,7 @@ private SqlBinaryExpression MakeStartsWithExpressionImpl(
SqlExpression prefix,
SqlExpression? originalPrefix = null)
{
- return _sqlExpressionFactory.AndAlso(
+ return (SqlBinaryExpression)_sqlExpressionFactory.AndAlso(
_sqlExpressionFactory.Like(
target,
_sqlExpressionFactory.ApplyDefaultTypeMapping(_sqlExpressionFactory.Function(
@@ -286,6 +330,7 @@ private SqlBinaryExpression MakeStartsWithExpressionImpl(
}
else
{
+#if !NET8_0_OR_GREATER
return new CaseExpression(
new[]
{
@@ -306,6 +351,28 @@ private SqlBinaryExpression MakeStartsWithExpressionImpl(
suffix
)
);
+#else
+ return new CaseExpression(
+ new[]
+ {
+ new CaseWhenClause(
+ _sqlExpressionFactory.In(stringComparison,(IReadOnlyList) _caseSensitiveComparisons),
+ // Case sensitive, accent sensitive
+ MakeEndsWithExpressionImpl(
+ target,
+ Utf8Bin(suffix),
+ suffix
+ )
+ )
+ },
+ // Case insensitive, accent sensitive
+ MakeEndsWithExpressionImpl(
+ LCase(target),
+ Utf8Bin(LCase(suffix)),
+ suffix
+ )
+ );
+#endif
}
}
@@ -379,6 +446,7 @@ private SqlExpression MakeEndsWithExpressionImpl(
}
else
{
+#if !NET8_0_OR_GREATER
return new CaseExpression(
new[]
{
@@ -401,6 +469,30 @@ private SqlExpression MakeEndsWithExpressionImpl(
e => Utf8Bin(LCase(e))
)
);
+#else
+ return new CaseExpression(
+ new[]
+ {
+ new CaseWhenClause(
+ _sqlExpressionFactory.In(stringComparison,(IReadOnlyList) _caseSensitiveComparisons),
+ // Case sensitive, accent sensitive
+ MakeContainsExpressionImpl(
+ target,
+ e => e,
+ search,
+ e => Utf8Bin(e)
+ )
+ )
+ },
+ // Case insensitive, accent sensitive
+ MakeContainsExpressionImpl(
+ target,
+ e => LCase(e),
+ search,
+ e => Utf8Bin(LCase(e))
+ )
+ );
+#endif
}
}
private SqlExpression MakeContainsExpressionImpl(
@@ -473,14 +565,12 @@ private SqlExpression MakeContainsExpressionImpl(
e => Utf8Bin(LCase(e))));
}
+#if !NET8_0_OR_GREATER
return _sqlExpressionFactory.Case(
new[]
{
new CaseWhenClause(
- _sqlExpressionFactory.In(
- stringComparison,
- _caseSensitiveComparisons,
- false),
+ _sqlExpressionFactory.In(stringComparison, _caseSensitiveComparisons, false),
// Case sensitive, accent sensitive
MakeIndexOfExpressionImpl(
target,
@@ -494,6 +584,26 @@ private SqlExpression MakeContainsExpressionImpl(
e => LCase(e),
search,
e => Utf8Bin(LCase(e))));
+#else
+ return _sqlExpressionFactory.Case(
+ new[]
+ {
+ new CaseWhenClause(
+ _sqlExpressionFactory.In(stringComparison, (IReadOnlyList)_caseSensitiveComparisons),
+ // Case sensitive, accent sensitive
+ MakeIndexOfExpressionImpl(
+ target,
+ e => e,
+ search,
+ e => Utf8Bin(e)))
+ },
+ // Case insensitive, accent sensitive
+ MakeIndexOfExpressionImpl(
+ target,
+ e => LCase(e),
+ search,
+ e => Utf8Bin(LCase(e))));
+#endif
}
private SqlExpression MakeIndexOfExpressionImpl(
diff --git a/EFCore/src/Query/Internal/MySQLCommandParser.cs b/EFCore/src/Query/Internal/MySQLCommandParser.cs
index 0552eef3d..9b4a36f4a 100644
--- a/EFCore/src/Query/Internal/MySQLCommandParser.cs
+++ b/EFCore/src/Query/Internal/MySQLCommandParser.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLCompatibilityExpressionVisitor.cs b/EFCore/src/Query/Internal/MySQLCompatibilityExpressionVisitor.cs
index f4207fbf2..492ed5957 100644
--- a/EFCore/src/Query/Internal/MySQLCompatibilityExpressionVisitor.cs
+++ b/EFCore/src/Query/Internal/MySQLCompatibilityExpressionVisitor.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -100,4 +100,4 @@ protected virtual Expression CheckTranslated(Expression? translated, Expression
return translated;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLCompiledQueryCacheKeyGenerator.cs b/EFCore/src/Query/Internal/MySQLCompiledQueryCacheKeyGenerator.cs
index d7ecb43d8..d4658704c 100644
--- a/EFCore/src/Query/Internal/MySQLCompiledQueryCacheKeyGenerator.cs
+++ b/EFCore/src/Query/Internal/MySQLCompiledQueryCacheKeyGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLConvertTranslator.cs b/EFCore/src/Query/Internal/MySQLConvertTranslator.cs
index 062f6d04b..f600784a9 100644
--- a/EFCore/src/Query/Internal/MySQLConvertTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLConvertTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -70,4 +70,4 @@ public MySQLConvertTranslator(ISqlExpressionFactory sqlExpressionFactory)
: null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLDateDiffFunctionsTranslator.cs b/EFCore/src/Query/Internal/MySQLDateDiffFunctionsTranslator.cs
index 1830ab451..439a3f2b3 100644
--- a/EFCore/src/Query/Internal/MySQLDateDiffFunctionsTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLDateDiffFunctionsTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -283,4 +283,4 @@ public MySQLDateDiffFunctionsTranslator(ISqlExpressionFactory sqlExpressionFacto
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLDateTimeMemberTranslator.cs b/EFCore/src/Query/Internal/MySQLDateTimeMemberTranslator.cs
index db8db62a4..b2c62c561 100644
--- a/EFCore/src/Query/Internal/MySQLDateTimeMemberTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLDateTimeMemberTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLDateTimeMethodTranslator.cs b/EFCore/src/Query/Internal/MySQLDateTimeMethodTranslator.cs
index e15e49787..dfb87f08c 100644
--- a/EFCore/src/Query/Internal/MySQLDateTimeMethodTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLDateTimeMethodTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -100,7 +100,11 @@ public MySQLDateTimeMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
typeof(string))
},
nullable: true,
+#if !NET9_0_OR_GREATER
argumentsPropagateNullability: TrueArrays[1],
+#else
+ argumentsPropagateNullability: new[] { true, false },
+#endif
instance!.Type,
instance.TypeMapping);
}
@@ -157,4 +161,4 @@ sqlConstantExpression.Value is TimeOnly timeOnly &&
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLEvaluatableExpressionFilter.cs b/EFCore/src/Query/Internal/MySQLEvaluatableExpressionFilter.cs
index f2a7de7b6..50d159ff5 100644
--- a/EFCore/src/Query/Internal/MySQLEvaluatableExpressionFilter.cs
+++ b/EFCore/src/Query/Internal/MySQLEvaluatableExpressionFilter.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLMathTranslator.cs b/EFCore/src/Query/Internal/MySQLMathTranslator.cs
index e820a0179..ba3f30f38 100644
--- a/EFCore/src/Query/Internal/MySQLMathTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLMathTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -134,4 +134,4 @@ public MySQLMathMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLMemberTranslatorProvider.cs b/EFCore/src/Query/Internal/MySQLMemberTranslatorProvider.cs
index d20c26c71..7d51db057 100644
--- a/EFCore/src/Query/Internal/MySQLMemberTranslatorProvider.cs
+++ b/EFCore/src/Query/Internal/MySQLMemberTranslatorProvider.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLMethodCallTranslatorProvider.cs b/EFCore/src/Query/Internal/MySQLMethodCallTranslatorProvider.cs
index 52fbce65c..3538d2342 100644
--- a/EFCore/src/Query/Internal/MySQLMethodCallTranslatorProvider.cs
+++ b/EFCore/src/Query/Internal/MySQLMethodCallTranslatorProvider.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLNewGuidTranslator.cs b/EFCore/src/Query/Internal/MySQLNewGuidTranslator.cs
index ddd0510b8..0a2cd57dd 100644
--- a/EFCore/src/Query/Internal/MySQLNewGuidTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLNewGuidTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -59,4 +59,4 @@ public MySQLNewGuidTranslator(ISqlExpressionFactory sqlExpressionFactory)
: null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLObjectToStringTranslator.cs b/EFCore/src/Query/Internal/MySQLObjectToStringTranslator.cs
index 2ece1937b..d8455bff7 100644
--- a/EFCore/src/Query/Internal/MySQLObjectToStringTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLObjectToStringTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -95,4 +95,4 @@ public MySQLObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFactory)
: null;
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessor.cs b/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessor.cs
index 10dd9070f..18633c334 100644
--- a/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessor.cs
+++ b/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessor.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -39,6 +39,7 @@ internal class MySQLParameterBasedSqlProcessor : RelationalParameterBasedSqlProc
{
private readonly IMySQLOptions _options;
+#if !NET9_0_OR_GREATER
public MySQLParameterBasedSqlProcessor(
RelationalParameterBasedSqlProcessorDependencies dependencies,
bool useRelationalNulls,
@@ -47,29 +48,35 @@ public MySQLParameterBasedSqlProcessor(
{
_options = options;
}
+#else
+ public MySQLParameterBasedSqlProcessor(
+ RelationalParameterBasedSqlProcessorDependencies dependencies,
+ RelationalParameterBasedSqlProcessorParameters parameters,
+ IMySQLOptions options)
+ : base(dependencies, parameters)
+ {
+ _options = options;
+ }
+#endif
///
-#if NET6_0
- protected override SelectExpression ProcessSqlNullability(
- SelectExpression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
+#if NET8_0
+ protected override Expression ProcessSqlNullability(
+ Expression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
{
Check.NotNull(selectExpression, nameof(selectExpression));
Check.NotNull(parametersValues, nameof(parametersValues));
- selectExpression = new MySQLSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(selectExpression, parametersValues, out canCache);
-
- selectExpression = (SelectExpression)new MySQLCompatibilityExpressionVisitor(_options).Visit(selectExpression);
-
- return selectExpression;
+ return new MySQLSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(selectExpression, parametersValues, out canCache);
}
-#elif NET7_0 || NET8_0
+#elif NET9_0_OR_GREATER
protected override Expression ProcessSqlNullability(
Expression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
{
Check.NotNull(selectExpression, nameof(selectExpression));
Check.NotNull(parametersValues, nameof(parametersValues));
- return new MySQLSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(selectExpression, parametersValues, out canCache);
+ return new MySQLSqlNullabilityProcessor(Dependencies, Parameters).Process(selectExpression, parametersValues, out canCache);
}
#endif
}
diff --git a/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessorFactory.cs b/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessorFactory.cs
index 463096bb3..de50f63d1 100644
--- a/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessorFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLParameterBasedSqlProcessorFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -42,7 +42,12 @@ public MySQLParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcess
_options = options;
}
+#if NET9_0_OR_GREATER
+ public RelationalParameterBasedSqlProcessor Create(RelationalParameterBasedSqlProcessorParameters parameters)
+ => new MySQLParameterBasedSqlProcessor(_dependencies, parameters, _options);
+#else
public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
=> new MySQLParameterBasedSqlProcessor(_dependencies, useRelationalNulls, _options);
+#endif
}
}
diff --git a/EFCore/src/Query/Internal/MySQLQueryCompilationContext.cs b/EFCore/src/Query/Internal/MySQLQueryCompilationContext.cs
index 79d755c11..821c3ac54 100644
--- a/EFCore/src/Query/Internal/MySQLQueryCompilationContext.cs
+++ b/EFCore/src/Query/Internal/MySQLQueryCompilationContext.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLQueryCompilationContextFactory.cs b/EFCore/src/Query/Internal/MySQLQueryCompilationContextFactory.cs
index 707d5c19d..3629a6424 100644
--- a/EFCore/src/Query/Internal/MySQLQueryCompilationContextFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLQueryCompilationContextFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLQueryStringFactory.cs b/EFCore/src/Query/Internal/MySQLQueryStringFactory.cs
index 112416908..caac3d8f1 100644
--- a/EFCore/src/Query/Internal/MySQLQueryStringFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLQueryStringFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessor.cs b/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessor.cs
index 913ace28f..5112c5e0c 100644
--- a/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessor.cs
+++ b/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessor.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -39,7 +39,7 @@ internal class MySQLQueryTranslationPostprocessor : RelationalQueryTranslationPo
public MySQLQueryTranslationPostprocessor(
QueryTranslationPostprocessorDependencies dependencies,
RelationalQueryTranslationPostprocessorDependencies relationalDependencies,
- QueryCompilationContext queryCompilationContext,
+ MySQLQueryCompilationContext queryCompilationContext,
IMySQLOptions options)
: base(dependencies, relationalDependencies, queryCompilationContext)
{
@@ -52,4 +52,4 @@ public override Expression Process(Expression query)
return new MySQLCompatibilityExpressionVisitor(_options).Visit(query);
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessorFactory.cs b/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessorFactory.cs
index 5bceb5265..147a36511 100644
--- a/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessorFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLQueryTranslationPostprocessorFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -51,7 +51,8 @@ public virtual QueryTranslationPostprocessor Create(QueryCompilationContext quer
=> new MySQLQueryTranslationPostprocessor(
_dependencies,
_relationalDependencies,
- queryCompilationContext,
+ (MySQLQueryCompilationContext)queryCompilationContext,
_options);
}
+
}
diff --git a/EFCore/src/Query/Internal/MySQLSqlExpressionFactory.cs b/EFCore/src/Query/Internal/MySQLSqlExpressionFactory.cs
index 270c91eea..da1883b17 100644
--- a/EFCore/src/Query/Internal/MySQLSqlExpressionFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLSqlExpressionFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -141,11 +141,18 @@ public MySQLCollateExpression Collate(
string charset,
string collation)
=> (MySQLCollateExpression)ApplyDefaultTypeMapping(
+#if NET9_0_OR_GREATER
+ new MySQLCollateExpression(
+ valueExpression,
+ collation)
+#else
new MySQLCollateExpression(
valueExpression,
charset,
collation,
- null));
+ null)
+#endif
+ );
public virtual MySQLBinaryExpression MySqlIntegerDivide(
SqlExpression left,
@@ -287,11 +294,15 @@ private MySQLCollateExpression ApplyTypeMappingOnCollate(MySQLCollateExpression
var inferredTypeMapping = ExpressionExtensions.InferTypeMapping(collateExpression.ValueExpression)
?? _typeMappingSource.FindMapping(collateExpression.ValueExpression.Type);
+#if NET9_0_OR_GREATER
+ return new MySQLCollateExpression(collateExpression.ValueExpression, collateExpression.Collation);
+#else
return new MySQLCollateExpression(
ApplyTypeMapping(collateExpression.ValueExpression, inferredTypeMapping),
collateExpression.Charset,
collateExpression.Collation,
inferredTypeMapping ?? collateExpression.TypeMapping);
+#endif
}
private SqlExpression ApplyTypeMappingOnRegexp(MySQLRegexpExpression regexpExpression)
diff --git a/EFCore/src/Query/Internal/MySQLSqlNullabilityProcessor.cs b/EFCore/src/Query/Internal/MySQLSqlNullabilityProcessor.cs
index 020b6202f..351fba69f 100644
--- a/EFCore/src/Query/Internal/MySQLSqlNullabilityProcessor.cs
+++ b/EFCore/src/Query/Internal/MySQLSqlNullabilityProcessor.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -37,6 +37,8 @@ internal class MySQLSqlNullabilityProcessor : SqlNullabilityProcessor
{
private readonly ISqlExpressionFactory _sqlExpressionFactory;
+
+#if !NET9_0_OR_GREATER
///
/// Creates a new instance of the .
///
@@ -47,7 +49,18 @@ public MySQLSqlNullabilityProcessor(
bool useRelationalNulls)
: base(dependencies, useRelationalNulls)
=> _sqlExpressionFactory = dependencies.SqlExpressionFactory;
-
+#else
+ ///
+ /// Creates a new instance of the .
+ ///
+ /// Parameter object containing dependencies for this class.
+ /// Parameter object containing parameters for this class.
+ public MySQLSqlNullabilityProcessor(
+ RelationalParameterBasedSqlProcessorDependencies dependencies,
+ RelationalParameterBasedSqlProcessorParameters parameters)
+ : base(dependencies, parameters)
+ => _sqlExpressionFactory = dependencies.SqlExpressionFactory;
+#endif
///
protected override SqlExpression VisitCustomSqlExpression(
SqlExpression sqlExpression, bool allowOptimizedExpansion, out bool nullable)
diff --git a/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitor.cs b/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitor.cs
index 763fee196..6ee7e7c35 100644
--- a/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitor.cs
+++ b/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitor.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -122,4 +122,4 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression)
private static string? GetProviderType(SqlExpression expression)
=> expression.TypeMapping?.StoreType;
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitorFactory.cs b/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitorFactory.cs
index 060d00609..7e476ba9d 100644
--- a/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitorFactory.cs
+++ b/EFCore/src/Query/Internal/MySQLSqlTranslatingExpressionVisitorFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -45,7 +45,7 @@ public virtual RelationalSqlTranslatingExpressionVisitor Create(
QueryableMethodTranslatingExpressionVisitor queryableMethodTranslatingExpressionVisitor)
=> new MySQLSqlTranslatingExpressionVisitor(
_dependencies,
- model,
+ (MySQLQueryCompilationContext)model,
queryableMethodTranslatingExpressionVisitor);
}
}
diff --git a/EFCore/src/Query/Internal/MySQLStringMemberTranslator.cs b/EFCore/src/Query/Internal/MySQLStringMemberTranslator.cs
index b9a6a150c..1dee350d7 100644
--- a/EFCore/src/Query/Internal/MySQLStringMemberTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLStringMemberTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs
index ed9a719be..c3697e56c 100644
--- a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs
+++ b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -290,4 +290,4 @@ private SqlExpression ProcessTrimMethod(SqlExpression instance, SqlExpression? t
typeof(string));
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Query/MySQLJsonString.cs b/EFCore/src/Query/MySQLJsonString.cs
index 0a4e01128..809869338 100644
--- a/EFCore/src/Query/MySQLJsonString.cs
+++ b/EFCore/src/Query/MySQLJsonString.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Sql/Internal/MySQLQueryGeneratorFactory.cs b/EFCore/src/Query/Sql/Internal/MySQLQueryGeneratorFactory.cs
index cc27aef05..75844a37e 100644
--- a/EFCore/src/Query/Sql/Internal/MySQLQueryGeneratorFactory.cs
+++ b/EFCore/src/Query/Sql/Internal/MySQLQueryGeneratorFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Query/Sql/Internal/MySQLQuerySqlGenerator.cs b/EFCore/src/Query/Sql/Internal/MySQLQuerySqlGenerator.cs
index e8f57ed72..e986d1f97 100644
--- a/EFCore/src/Query/Sql/Internal/MySQLQuerySqlGenerator.cs
+++ b/EFCore/src/Query/Sql/Internal/MySQLQuerySqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Scaffolding/Internal/MySQLCodeGenerator.cs b/EFCore/src/Scaffolding/Internal/MySQLCodeGenerator.cs
index a56c916a4..51b081e41 100644
--- a/EFCore/src/Scaffolding/Internal/MySQLCodeGenerator.cs
+++ b/EFCore/src/Scaffolding/Internal/MySQLCodeGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -55,4 +55,4 @@ public override MethodCallCodeFragment GenerateUseProvider(string connectionStri
? new object[] { connectionString }
: new object[] { connectionString, new NestedClosureCodeFragment("x", providerOptions) });
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Scaffolding/Internal/MySQLDataReaderExtension.cs b/EFCore/src/Scaffolding/Internal/MySQLDataReaderExtension.cs
index c6a31e83c..a68236874 100644
--- a/EFCore/src/Scaffolding/Internal/MySQLDataReaderExtension.cs
+++ b/EFCore/src/Scaffolding/Internal/MySQLDataReaderExtension.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Scaffolding/Internal/MySQLDatabaseModelFactory.cs b/EFCore/src/Scaffolding/Internal/MySQLDatabaseModelFactory.cs
index a6da60526..9818f28dc 100644
--- a/EFCore/src/Scaffolding/Internal/MySQLDatabaseModelFactory.cs
+++ b/EFCore/src/Scaffolding/Internal/MySQLDatabaseModelFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/ByteArrayComparer.cs b/EFCore/src/Storage/Internal/ByteArrayComparer.cs
index b76ee8cef..c99fda081 100644
--- a/EFCore/src/Storage/Internal/ByteArrayComparer.cs
+++ b/EFCore/src/Storage/Internal/ByteArrayComparer.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -44,4 +44,4 @@ public ByteArrayComparer()
{
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/BytesToDateTimeConverter.cs b/EFCore/src/Storage/Internal/BytesToDateTimeConverter.cs
index c3a588208..d92aefb1d 100644
--- a/EFCore/src/Storage/Internal/BytesToDateTimeConverter.cs
+++ b/EFCore/src/Storage/Internal/BytesToDateTimeConverter.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -43,4 +43,4 @@ public BytesToDateTimeConverter()
{
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/IMySQLRelationalConnection.cs b/EFCore/src/Storage/Internal/IMySQLRelationalConnection.cs
index 5e0e661b3..32a6c4ae9 100644
--- a/EFCore/src/Storage/Internal/IMySQLRelationalConnection.cs
+++ b/EFCore/src/Storage/Internal/IMySQLRelationalConnection.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,4 +34,4 @@ internal interface IMySQLRelationalConnection : IRelationalConnection
{
IMySQLRelationalConnection CreateSourceConnection();
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLBoolTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLBoolTypeMapping.cs
index e413ec50d..f1b7d2148 100644
--- a/EFCore/src/Storage/Internal/MySQLBoolTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLBoolTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -62,4 +62,4 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p
protected override string GenerateNonNullSqlLiteral(object value)
=> (bool)value ? "TRUE" : "FALSE";
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLByteArrayTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLByteArrayTypeMapping.cs
index d81006957..f95732c81 100644
--- a/EFCore/src/Storage/Internal/MySQLByteArrayTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLByteArrayTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -36,7 +36,7 @@ namespace MySql.EntityFrameworkCore.Storage.Internal
{
internal class MySQLByteArrayTypeMapping : ByteArrayTypeMapping
{
- private const int MaxSize = 8000;
+ private const int MaxSize = System.Int32.MaxValue;
private readonly int _maxSpecificSize;
@@ -117,4 +117,4 @@ protected override void ConfigureParameter(DbParameter parameter)
///
protected override string GenerateNonNullSqlLiteral(object value) => ByteArrayFormatter.ToHex((byte[])value);
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLDatabaseCreator.cs b/EFCore/src/Storage/Internal/MySQLDatabaseCreator.cs
index 613713a67..21ef77904 100644
--- a/EFCore/src/Storage/Internal/MySQLDatabaseCreator.cs
+++ b/EFCore/src/Storage/Internal/MySQLDatabaseCreator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -268,4 +268,4 @@ private IReadOnlyList CreateDropCommands()
// invalid connection may now be valid.
private void ClearPool() => MySqlConnection.ClearPool((MySqlConnection)_connection.DbConnection);
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLDateTimeOffsetTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLDateTimeOffsetTypeMapping.cs
index adf4c952f..d63ac03bf 100644
--- a/EFCore/src/Storage/Internal/MySQLDateTimeOffsetTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLDateTimeOffsetTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLDateTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLDateTypeMapping.cs
index 21e67c90e..68f939a73 100644
--- a/EFCore/src/Storage/Internal/MySQLDateTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLDateTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLDatetimeTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLDatetimeTypeMapping.cs
index 69ba0b5de..269566f6c 100644
--- a/EFCore/src/Storage/Internal/MySQLDatetimeTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLDatetimeTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -112,4 +112,4 @@ protected override void ConfigureParameter([NotNull] DbParameter parameter)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLDecimalTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLDecimalTypeMapping.cs
index 50170708a..1520a8164 100644
--- a/EFCore/src/Storage/Internal/MySQLDecimalTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLDecimalTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLDoubleTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLDoubleTypeMapping.cs
index be2f8e4b6..401846f59 100644
--- a/EFCore/src/Storage/Internal/MySQLDoubleTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLDoubleTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLExecutionStrategy.cs b/EFCore/src/Storage/Internal/MySQLExecutionStrategy.cs
index ba3fad038..cc0793aa7 100644
--- a/EFCore/src/Storage/Internal/MySQLExecutionStrategy.cs
+++ b/EFCore/src/Storage/Internal/MySQLExecutionStrategy.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLExecutionStrategyFactory.cs b/EFCore/src/Storage/Internal/MySQLExecutionStrategyFactory.cs
index a6663fba1..b7caac1b4 100644
--- a/EFCore/src/Storage/Internal/MySQLExecutionStrategyFactory.cs
+++ b/EFCore/src/Storage/Internal/MySQLExecutionStrategyFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -42,4 +42,4 @@ public MySQLExecutionStrategyFactory(
protected override IExecutionStrategy CreateDefaultStrategy(ExecutionStrategyDependencies dependencies)
=> new MySQLExecutionStrategy(dependencies);
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLFloatTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLFloatTypeMapping.cs
index 497cb11d7..9db0bee5e 100644
--- a/EFCore/src/Storage/Internal/MySQLFloatTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLFloatTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLGeometryTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLGeometryTypeMapping.cs
index 73ad2d675..deb61e2c0 100644
--- a/EFCore/src/Storage/Internal/MySQLGeometryTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLGeometryTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -43,8 +43,13 @@ protected MySQLGeometryTypeMapping(RelationalTypeMappingParameters parameters)
{
}
+#if NET8_0_OR_GREATER
+ public CoreTypeMapping Clone(ValueConverter? converter)
+ => new MySQLGeometryTypeMapping(Parameters.WithComposedConverter(converter,null,null,null,null));
+#else
public override CoreTypeMapping Clone(ValueConverter? converter)
=> new MySQLGeometryTypeMapping(Parameters.WithComposedConverter(converter));
+#endif
protected override void ConfigureParameter(DbParameter parameter)
{
@@ -67,4 +72,4 @@ public MySQLGeometryTypeMapping(
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
=> new MySQLGeometryTypeMapping(parameters);
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLGuidTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLGuidTypeMapping.cs
index aa0f06880..3aee65a32 100644
--- a/EFCore/src/Storage/Internal/MySQLGuidTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLGuidTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLJsonChangeTrackingOptions.cs b/EFCore/src/Storage/Internal/MySQLJsonChangeTrackingOptions.cs
index 07a5cd07b..2e7ab243c 100644
--- a/EFCore/src/Storage/Internal/MySQLJsonChangeTrackingOptions.cs
+++ b/EFCore/src/Storage/Internal/MySQLJsonChangeTrackingOptions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLJsonTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLJsonTypeMapping.cs
index b8052d70d..332ca01ee 100644
--- a/EFCore/src/Storage/Internal/MySQLJsonTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLJsonTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLRelationalConnection.cs b/EFCore/src/Storage/Internal/MySQLRelationalConnection.cs
index b2f2c0cb2..cc1e391e7 100644
--- a/EFCore/src/Storage/Internal/MySQLRelationalConnection.cs
+++ b/EFCore/src/Storage/Internal/MySQLRelationalConnection.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -83,13 +83,17 @@ public virtual IMySQLRelationalConnection CreateSourceConnection()
public override bool Open(bool errorsExpected = false)
{
+ if (DbConnection.IsDisposed)
+ DbConnection = (MySqlConnection)CreateDbConnection();
var result = base.Open(errorsExpected);
return result;
}
public override async Task OpenAsync(CancellationToken cancellationToken, bool errorsExpected = false)
{
+ if (DbConnection.IsDisposed)
+ DbConnection = (MySqlConnection)CreateDbConnection();
return await base.OpenAsync(cancellationToken, errorsExpected).ConfigureAwait(false);
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLScaffoldingConnectionSettings.cs b/EFCore/src/Storage/Internal/MySQLScaffoldingConnectionSettings.cs
index 1f00a09e2..9f4b301f7 100644
--- a/EFCore/src/Storage/Internal/MySQLScaffoldingConnectionSettings.cs
+++ b/EFCore/src/Storage/Internal/MySQLScaffoldingConnectionSettings.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLSqlGenerationHelper.cs b/EFCore/src/Storage/Internal/MySQLSqlGenerationHelper.cs
index b50d44974..4bcb445f6 100644
--- a/EFCore/src/Storage/Internal/MySQLSqlGenerationHelper.cs
+++ b/EFCore/src/Storage/Internal/MySQLSqlGenerationHelper.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -83,6 +83,6 @@ protected virtual string GetObjectName(string name, string schema)
? _options.SchemaNameTranslator(schema, name)
: name;
- protected virtual string? GetSchemaName(string name, string schema) => null;
+ protected virtual string? GetSchemaName(string name, string schema) => schema;
}
}
diff --git a/EFCore/src/Storage/Internal/MySQLStringTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLStringTypeMapping.cs
index 711b103d0..4979b239f 100644
--- a/EFCore/src/Storage/Internal/MySQLStringTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLStringTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLTimeSpanMapping.cs b/EFCore/src/Storage/Internal/MySQLTimeSpanMapping.cs
index ebcd357b5..9af35fb0a 100644
--- a/EFCore/src/Storage/Internal/MySQLTimeSpanMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLTimeSpanMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLTransientExceptionDetector.cs b/EFCore/src/Storage/Internal/MySQLTransientExceptionDetector.cs
index d79c4bf49..d608ea6c7 100644
--- a/EFCore/src/Storage/Internal/MySQLTransientExceptionDetector.cs
+++ b/EFCore/src/Storage/Internal/MySQLTransientExceptionDetector.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -41,4 +41,4 @@ public static bool ShouldRetryOn([NotNull] Exception ex)
? mySqlException.IsTransient
: ex is TimeoutException;
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Storage/Internal/MySQLTypeMapping.cs b/EFCore/src/Storage/Internal/MySQLTypeMapping.cs
index b41ae11f4..94b3ba746 100644
--- a/EFCore/src/Storage/Internal/MySQLTypeMapping.cs
+++ b/EFCore/src/Storage/Internal/MySQLTypeMapping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Storage/Internal/MySQLTypeMappingSource.cs b/EFCore/src/Storage/Internal/MySQLTypeMappingSource.cs
index 229bf8ab2..831d01a94 100644
--- a/EFCore/src/Storage/Internal/MySQLTypeMappingSource.cs
+++ b/EFCore/src/Storage/Internal/MySQLTypeMappingSource.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -187,12 +187,21 @@ protected void Initialize()
{ typeof(byte), _utinyint },
{ typeof(sbyte), _tinyint },
+ #if !NET8_0_OR_GREATER
// DateTime
{ typeof(DateTime), _datetime.Clone(6, null) },
{ typeof(DateOnly), _dateonly },
{ typeof(DateTimeOffset), _datetimeoffset.Clone(6, null) },
{ typeof(TimeSpan), _time.Clone(6, null) },
{ typeof(TimeOnly), _timeonly },
+ #else
+ // DateTime
+ { typeof(DateTime), _datetime.WithPrecisionAndScale(6, null) },
+ { typeof(DateOnly), _dateonly },
+ { typeof(DateTimeOffset), _datetimeoffset.Clone() },
+ { typeof(TimeSpan), _time.WithPrecisionAndScale(6, null) },
+ { typeof(TimeOnly), _timeonly },
+ #endif
// decimals
{ typeof(float), _float },
@@ -243,9 +252,15 @@ protected void Initialize()
if (_storeTypeMappings.TryGetValue(storeTypeNameBase!, out mapping))
{
+#if !NET8_0_OR_GREATER
return clrType == null
? mapping[0].Clone(in mappingInfo)
: mapping.FirstOrDefault(m => m.ClrType == clrType)?.Clone(in mappingInfo);
+#else
+ return clrType == null
+ ? mapping[0].WithTypeMappingInfo(mappingInfo)
+ : mapping.FirstOrDefault(m => m.ClrType == clrType)?.WithTypeMappingInfo(mappingInfo);
+#endif
}
}
@@ -259,7 +274,11 @@ protected void Initialize()
clrType == typeof(DateTimeOffset) ||
clrType == typeof(TimeSpan))
{
+#if !NET8_0_OR_GREATER
return mapping.Clone(mappingInfo.Precision.Value, null);
+#else
+ return mapping.WithPrecisionAndScale(mappingInfo.Precision.Value, null);
+#endif
}
}
@@ -282,7 +301,11 @@ protected void Initialize()
mapping = isFixedLength ? _charUnicode : size == null
? _longtextUnicode : _varcharUnicode;
+#if !NET8_0_OR_GREATER
return size == null ? mapping : mapping.Clone($"{mapping.StoreTypeNameBase}({size})", size);
+#else
+ return size == null ? mapping : mapping.WithStoreTypeAndSize($"{mapping.StoreTypeNameBase}({size})", size);
+#endif
}
else if (clrType == typeof(byte[]))
{
@@ -297,6 +320,7 @@ protected void Initialize()
return null;
}
+#if !NET8_0_OR_GREATER
protected override string ParseStoreTypeName(string? storeTypeName, out bool? unicode, out int? size, out int? precision, out int? scale)
{
var storeTypeBaseName = base.ParseStoreTypeName(storeTypeName, out unicode, out size, out precision, out scale);
@@ -305,5 +329,15 @@ protected override string ParseStoreTypeName(string? storeTypeName, out bool? un
? storeTypeBaseName + " unsigned"
: storeTypeBaseName!;
}
+#else
+ protected string ParseStoreTypeName(string? storeTypeName, ref bool? unicode, ref int? size, ref int? precision, ref int? scale)
+ {
+ var storeTypeBaseName = base.ParseStoreTypeName(storeTypeName, ref unicode, ref size, ref precision, ref scale);
+
+ return (storeTypeName?.IndexOf("unsigned", StringComparison.OrdinalIgnoreCase) ?? -1) >= 0
+ ? storeTypeBaseName + " unsigned"
+ : storeTypeBaseName!;
+ }
+#endif
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Update/IMySQLUpdateSqlGenerator.cs b/EFCore/src/Update/IMySQLUpdateSqlGenerator.cs
index 30dcfd871..c27d2f48d 100644
--- a/EFCore/src/Update/IMySQLUpdateSqlGenerator.cs
+++ b/EFCore/src/Update/IMySQLUpdateSqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,15 +34,6 @@
namespace MySql.EntityFrameworkCore.Update
{
-#if NET6_0
- internal interface IMySQLUpdateSqlGenerator : IUpdateSqlGenerator
- {
- ResultSetMapping AppendBulkInsertOperation(
- [NotNull] StringBuilder commandStringBuilder,
- [NotNull] IReadOnlyList modificationCommands,
- int commandPosition);
- }
-#elif NET7_0 || NET8_0
///
///
/// The service lifetime is . This means a single instance
@@ -70,6 +61,5 @@ ResultSetMapping AppendBulkInsertOperation(
int commandPosition)
=> AppendBulkInsertOperation(commandStringBuilder, modificationCommands, commandPosition, out _);
}
-#endif
}
diff --git a/EFCore/src/Update/MySQLModificationCommandBatch.cs b/EFCore/src/Update/MySQLModificationCommandBatch.cs
index 960e4f9f8..bb93a4762 100644
--- a/EFCore/src/Update/MySQLModificationCommandBatch.cs
+++ b/EFCore/src/Update/MySQLModificationCommandBatch.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -49,158 +49,14 @@ internal class MySQLModificationCommandBatch : AffectedCountModificationCommandB
private const int DefaultNetworkPacketSizeBytes = 4096;
private const int MaxScriptLength = 65536 * DefaultNetworkPacketSizeBytes / 2;
private const int MaxParameterCount = 2100;
-#if NET6_0
- private const int MaxRowCount = 1000;
- private int _parameterCount = 1; // Implicit parameter for the command text
- private readonly int _maxBatchSize;
- private readonly List _bulkInsertCommands = new List();
- private int _commandsLeftToLengthCheck = 50;
-#elif NET7_0 || NET8_0
private readonly List _pendingBulkInsertCommands = new();
-#endif
+
protected new virtual IMySQLUpdateSqlGenerator UpdateSqlGenerator => (IMySQLUpdateSqlGenerator)base.UpdateSqlGenerator;
-#if NET6_0
- public MySQLModificationCommandBatch(
- [NotNull] ModificationCommandBatchFactoryDependencies dependencies,
- int? maxBatchSize)
- : base(dependencies)
- {
- if (maxBatchSize.HasValue
- && maxBatchSize.Value <= 0)
- {
- throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize(maxBatchSize));
- }
-
- _maxBatchSize = Math.Min(maxBatchSize ?? int.MaxValue, MaxRowCount);
- }
-
- protected override bool CanAddCommand(IReadOnlyModificationCommand modificationCommand)
- {
- if (ModificationCommands.Count >= _maxBatchSize)
- {
- return false;
- }
-
- var additionalParameterCount = CountParameters(modificationCommand);
-
- if (_parameterCount + additionalParameterCount >= MaxParameterCount)
- {
- return false;
- }
-
- _parameterCount += additionalParameterCount;
- return true;
- }
-
- private static int CountParameters(IReadOnlyModificationCommand modificationCommand)
- {
- var parameterCount = 0;
-
- foreach (var columnModification in modificationCommand.ColumnModifications)
- {
- if (columnModification.UseCurrentValueParameter)
- {
- parameterCount++;
- }
-
- if (columnModification.UseOriginalValueParameter)
- {
- parameterCount++;
- }
- }
-
- return parameterCount;
- }
-
- ///
- protected override bool IsCommandTextValid()
- {
- if (--_commandsLeftToLengthCheck < 0)
- {
- var commandTextLength = GetCommandText().Length;
- if (commandTextLength >= MaxScriptLength)
- {
- return false;
- }
-
- var averageCommandLength = commandTextLength / ModificationCommands.Count;
- var expectedAdditionalCommandCapacity = (MaxScriptLength - commandTextLength) / averageCommandLength;
- _commandsLeftToLengthCheck = Math.Max(1, expectedAdditionalCommandCapacity / 4);
- }
-
- return true;
- }
-
- ///
- protected override int GetParameterCount()
- => _parameterCount;
-
- ///
- protected override void ResetCommandText()
- {
- base.ResetCommandText();
- _bulkInsertCommands.Clear();
- }
-
- ///
- protected override string GetCommandText()
- => base.GetCommandText() + GetBulkInsertCommandText(ModificationCommands.Count);
-
- private string GetBulkInsertCommandText(int lastIndex)
- {
- if (_bulkInsertCommands.Count == 0)
- {
- return string.Empty;
- }
-
- var stringBuilder = new StringBuilder();
- var resultSetMapping = UpdateSqlGenerator.AppendBulkInsertOperation(
- stringBuilder, _bulkInsertCommands, lastIndex - _bulkInsertCommands.Count);
- for (var i = lastIndex - _bulkInsertCommands.Count; i < lastIndex; i++)
- {
- CommandResultSet[i] = resultSetMapping;
- }
-
- if (resultSetMapping != ResultSetMapping.NoResultSet)
- {
- CommandResultSet[lastIndex - 1] = ResultSetMapping.LastInResultSet;
- }
-
- return stringBuilder.ToString();
- }
-
- ///
- protected override void UpdateCachedCommandText(int commandPosition)
- {
- var newModificationCommand = ModificationCommands[commandPosition];
- if (newModificationCommand.EntityState == EntityState.Added)
- {
- if (_bulkInsertCommands.Count > 0
- && !CanBeInsertedInSameStatement(_bulkInsertCommands[0], (ModificationCommand)newModificationCommand))
- {
- CachedCommandText.Append(GetBulkInsertCommandText(commandPosition));
- _bulkInsertCommands.Clear();
- }
-
- _bulkInsertCommands.Add((ModificationCommand)newModificationCommand);
-
- LastCachedCommandIndex = commandPosition;
- }
- else
- {
- CachedCommandText.Append(GetBulkInsertCommandText(commandPosition));
- _bulkInsertCommands.Clear();
-
- base.UpdateCachedCommandText(commandPosition);
- }
- }
-
-#elif NET7_0 || NET8_0
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -322,7 +178,6 @@ public override async Task ExecuteAsync(IRelationalConnection connection, Cancel
throw new DbUpdateException(MySQLStrings.SaveChangesFailed, e.InnerException, e.Entries);
}
}
-#endif
private static bool CanBeInsertedInSameStatement(
diff --git a/EFCore/src/Update/MySQLModificationCommandBatchFactory.cs b/EFCore/src/Update/MySQLModificationCommandBatchFactory.cs
index 7991ef136..e03dd8e76 100644
--- a/EFCore/src/Update/MySQLModificationCommandBatchFactory.cs
+++ b/EFCore/src/Update/MySQLModificationCommandBatchFactory.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Update/MySQLUpdateSqlGenerator.cs b/EFCore/src/Update/MySQLUpdateSqlGenerator.cs
index 3487e1cea..7caf477ec 100644
--- a/EFCore/src/Update/MySQLUpdateSqlGenerator.cs
+++ b/EFCore/src/Update/MySQLUpdateSqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -50,190 +50,14 @@ namespace MySql.EntityFrameworkCore
/// This service cannot depend on services registered as .
///
///
- internal class MySQLUpdateSqlGenerator : UpdateSqlGenerator, IMySQLUpdateSqlGenerator
+ internal class MySQLUpdateSqlGenerator : UpdateAndSelectSqlGenerator, IMySQLUpdateSqlGenerator
{
public MySQLUpdateSqlGenerator([NotNull] UpdateSqlGeneratorDependencies dependencies)
: base(dependencies)
{
}
-#if NET6_0
- public virtual ResultSetMapping AppendBulkInsertOperation(
- StringBuilder commandStringBuilder,
- IReadOnlyList modificationCommands,
- int commandPosition)
- {
- var table = StoreObjectIdentifier.Table(modificationCommands[0].TableName, modificationCommands[0].Schema);
- if (modificationCommands.Count == 1
- && modificationCommands[0].ColumnModifications.All(
- o => !o.IsKey
- || !o.IsRead
- || o.Property?.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn))
- {
- return AppendInsertOperation(commandStringBuilder, modificationCommands[0], commandPosition);
- }
-
- var readOperations = modificationCommands[0].ColumnModifications.Where(o => o.IsRead).ToList();
- var writeOperations = modificationCommands[0].ColumnModifications.Where(o => o.IsWrite).ToList();
- var keyOperations = modificationCommands[0].ColumnModifications.Where(o => o.IsKey).ToList();
-
- var defaultValuesOnly = writeOperations.Count == 0;
- var nonIdentityOperations = modificationCommands[0].ColumnModifications
- .Where(o => o.Property?.GetValueGenerationStrategy(table) != MySQLValueGenerationStrategy.IdentityColumn)
- .ToList();
-
- if (defaultValuesOnly)
- {
- if (nonIdentityOperations.Count == 0 || readOperations.Count == 0)
- {
- foreach (var modification in modificationCommands)
- {
- AppendInsertOperation(commandStringBuilder, modification, commandPosition);
- }
-
- return readOperations.Count == 0
- ? ResultSetMapping.NoResultSet
- : ResultSetMapping.LastInResultSet;
- }
-
- if (nonIdentityOperations.Count > 1)
- {
- nonIdentityOperations = new List { nonIdentityOperations.First() };
- }
- }
-
- if (readOperations.Count == 0)
- {
- return AppendBulkInsertWithoutServerValues(commandStringBuilder, modificationCommands, writeOperations);
- }
-
- foreach (var modification in modificationCommands)
- {
- AppendInsertOperation(commandStringBuilder, modification, commandPosition);
- }
-
- return ResultSetMapping.LastInResultSet;
- }
-
- private ResultSetMapping AppendBulkInsertWithoutServerValues(
- StringBuilder commandStringBuilder,
- IReadOnlyList modificationCommands,
- List writeOperations)
- {
- Debug.Assert(writeOperations.Count > 0);
-
- var name = modificationCommands[0].TableName;
- var schema = modificationCommands[0].Schema;
-
- AppendInsertCommandHeader(commandStringBuilder, name, schema, writeOperations);
- AppendValuesHeader(commandStringBuilder, writeOperations);
- AppendValues(commandStringBuilder, string.Empty, null, writeOperations);
- for (var i = 1; i < modificationCommands.Count; i++)
- {
- commandStringBuilder.Append(",").AppendLine();
- AppendValues(commandStringBuilder, string.Empty, null, modificationCommands[i].ColumnModifications.Where(o => o.IsWrite).ToList());
- }
- commandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();
-
- return ResultSetMapping.NoResultSet;
- }
-
- protected override void AppendInsertCommandHeader(
- [NotNull] StringBuilder commandStringBuilder,
- [NotNull] string name,
- string? schema,
- [NotNull] IReadOnlyList operations)
- {
- Check.NotNull(commandStringBuilder, nameof(commandStringBuilder));
- Check.NotEmpty(name, nameof(name));
- Check.NotNull(operations, nameof(operations));
-
- base.AppendInsertCommandHeader(commandStringBuilder, name, schema, operations);
-
- if (operations.Count <= 0)
- {
- commandStringBuilder.Append(" ()");
- }
- }
-
- protected override void AppendValuesHeader(
- [NotNull] StringBuilder commandStringBuilder,
- [NotNull] IReadOnlyList operations)
- {
- Check.NotNull(commandStringBuilder, nameof(commandStringBuilder));
- Check.NotNull(operations, nameof(operations));
-
- commandStringBuilder.AppendLine();
- commandStringBuilder.Append("VALUES ");
- }
-
- protected override void AppendValues(
- [NotNull] StringBuilder commandStringBuilder,
- [NotNull] string name,
- string? schema,
- [NotNull] IReadOnlyList operations)
- {
- base.AppendValues(commandStringBuilder, name, schema, operations);
-
- if (operations.Count <= 0)
- {
- commandStringBuilder.Append("()");
- }
- }
-
- protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, IColumnModification columnModification)
- {
- Check.NotNull(columnModification, "columnModification");
- Check.NotNull(commandStringBuilder, "commandStringBuilder");
- commandStringBuilder.AppendFormat("{0} = LAST_INSERT_ID()", SqlGenerationHelper.DelimitIdentifier(columnModification.ColumnName));
- }
-
- protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)
- {
- Check.NotNull(commandStringBuilder, "commandStringBuilder");
- commandStringBuilder
- .Append("ROW_COUNT() = " + expectedRowsAffected.ToString(CultureInfo.InvariantCulture));
- }
-
- protected override ResultSetMapping AppendSelectAffectedCountCommand(StringBuilder commandStringBuilder, string name, string? schemaName, int commandPosition)
- {
- Check.NotNull(commandStringBuilder, "commandStringBuilder");
- Check.NotEmpty(name, "name");
-
- commandStringBuilder
- .Append("SELECT ROW_COUNT()")
- .Append(SqlGenerationHelper.StatementTerminator).AppendLine()
- .AppendLine();
-
- return ResultSetMapping.LastInResultSet;
- }
-
- protected override void AppendWhereAffectedClause(
- [NotNull] StringBuilder commandStringBuilder,
- [NotNull] IReadOnlyList operations)
- {
- Check.NotNull(commandStringBuilder, nameof(commandStringBuilder));
- Check.NotNull(operations, nameof(operations));
-
- var nonDefaultOperations = operations
- .Where(
- o => !o.IsKey ||
- !o.IsRead ||
- o.Property == null ||
- !o.Property.ValueGenerated.HasFlag(ValueGenerated.OnAdd) ||
- MySQLPropertyExtensions.IsCompatibleAutoIncrementColumn(o.Property))
- .ToList()
- .AsReadOnly();
-
- base.AppendWhereAffectedClause(commandStringBuilder, nonDefaultOperations);
- }
-
- internal enum ResultsGrouping
- {
- OneResultSet,
- OneCommandPerResultSet
- }
-#elif NET7_0 || NET8_0
+#if NET8_0_OR_GREATER
public virtual ResultSetMapping AppendBulkInsertOperation(
StringBuilder commandStringBuilder,
IReadOnlyList modificationCommands,
@@ -250,7 +74,7 @@ public virtual ResultSetMapping AppendBulkInsertOperation(
|| !o.IsRead
|| o.Property?.GetValueGenerationStrategy(table) == MySQLValueGenerationStrategy.IdentityColumn))
{
- return AppendInsertOperation(commandStringBuilder, firstCommand, commandPosition, false, out requiresTransaction);
+ return AppendInsertOperation(commandStringBuilder, firstCommand, commandPosition, out requiresTransaction);
}
var readOperations = firstCommand.ColumnModifications.Where(o => o.IsRead).ToList();
@@ -291,7 +115,7 @@ public virtual ResultSetMapping AppendBulkInsertOperation(
foreach (var modification in modificationCommands)
{
- AppendInsertOperation(commandStringBuilder, modification, commandPosition, false, out requiresTransaction);
+ AppendInsertOperation(commandStringBuilder, modification, commandPosition, out requiresTransaction);
}
return ResultSetMapping.LastInResultSet;
@@ -355,7 +179,7 @@ public virtual ResultSetMapping AppendInsertOperation(
return AppendSelectAffectedCommand(commandStringBuilder, name, schema, readOperations, keyOperations);
}
- return readOperations.Count > 0 ? ResultSetMapping.LastInResultSet : ResultSetMapping.NoResults;
+ return AppendSelectAffectedCountCommand(commandStringBuilder, name, schema, commandPosition);
}
protected virtual void AppendInsertCommand(
@@ -399,7 +223,7 @@ public override ResultSetMapping AppendUpdateOperation(
return AppendSelectAffectedCommand(commandStringBuilder, name, schema, readOperations, keyOperations);
}
- return ResultSetMapping.NoResults;
+ return AppendSelectAffectedCountCommand(commandStringBuilder, name, schema, commandPosition);
}
public override ResultSetMapping AppendDeleteOperation(
@@ -418,7 +242,7 @@ public override ResultSetMapping AppendDeleteOperation(
AppendDeleteCommand(commandStringBuilder, name, schema, Array.Empty(), conditionOperations);
- return ResultSetMapping.NoResults;
+ return AppendSelectAffectedCountCommand(commandStringBuilder, name, schema,commandPosition);
}
protected override void AppendValues(
@@ -551,7 +375,20 @@ protected virtual void AppendWhereAffectedClause(
}
}
- private void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)
+ protected override void AppendReturningClause(StringBuilder commandStringBuilder, IReadOnlyList operations, string? additionalValues = null)
+ {
+ if (additionalValues is not null)
+ {
+ if (operations.Count > 0)
+ {
+ commandStringBuilder.Append(", ");
+ }
+
+ commandStringBuilder.Append('1');
+ }
+ }
+
+ protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)
{
Check.NotNull(commandStringBuilder, "commandStringBuilder");
commandStringBuilder
@@ -566,14 +403,25 @@ private void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder
protected virtual bool IsIdentityOperation(IColumnModification modification)
=> modification.IsKey && modification.IsRead;
- private void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, IColumnModification columnModification)
+ protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, IColumnModification columnModification)
{
Check.NotNull(columnModification, "columnModification");
Check.NotNull(commandStringBuilder, "commandStringBuilder");
commandStringBuilder.AppendFormat("{0} = LAST_INSERT_ID()", SqlGenerationHelper.DelimitIdentifier(columnModification.ColumnName));
}
-#endif
+ protected override ResultSetMapping AppendSelectAffectedCountCommand(StringBuilder commandStringBuilder, string name, string? schemaName, int commandPosition)
+ {
+ Check.NotNull(commandStringBuilder, "commandStringBuilder");
+ Check.NotEmpty(name, "name");
+
+ commandStringBuilder
+ .Append("SELECT ROW_COUNT()")
+ .Append(SqlGenerationHelper.StatementTerminator).AppendLine()
+ .AppendLine();
+ return ResultSetMapping.ResultSetWithRowsAffectedOnly;
+ }
+#endif
}
}
diff --git a/EFCore/src/Utils/Check.cs b/EFCore/src/Utils/Check.cs
index 8a3aed11d..2b6408fdb 100644
--- a/EFCore/src/Utils/Check.cs
+++ b/EFCore/src/Utils/Check.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Utils/CodeAnnotations.cs b/EFCore/src/Utils/CodeAnnotations.cs
index 6556044ad..1ee0e5880 100644
--- a/EFCore/src/Utils/CodeAnnotations.cs
+++ b/EFCore/src/Utils/CodeAnnotations.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Utils/CodeAttributes.cs b/EFCore/src/Utils/CodeAttributes.cs
index e7c921ba5..dda508d4f 100644
--- a/EFCore/src/Utils/CodeAttributes.cs
+++ b/EFCore/src/Utils/CodeAttributes.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -35,4 +35,4 @@ internal sealed class NotNullAttribute : Attribute { }
[AttributeUsage(AttributeTargets.All)]
internal sealed class CanBeNullAttribute : Attribute { }
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Utils/SharedTypeExtensions.cs b/EFCore/src/Utils/SharedTypeExtensions.cs
index 800bbbbea..b09c5b396 100644
--- a/EFCore/src/Utils/SharedTypeExtensions.cs
+++ b/EFCore/src/Utils/SharedTypeExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -106,4 +106,4 @@ public static MethodInfo GetRequiredRuntimeMethod(this Type type, string name, p
=> type.GetTypeInfo().GetRuntimeMethod(name, parameters)
?? throw new InvalidOperationException($"Could not find method '{name}' on type '{type}'");
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/src/Utils/Static.cs b/EFCore/src/Utils/Static.cs
index 1d7578b46..42e67383d 100644
--- a/EFCore/src/Utils/Static.cs
+++ b/EFCore/src/Utils/Static.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/Utils/StringBuilderExtensions.cs b/EFCore/src/Utils/StringBuilderExtensions.cs
index 046478b17..1a431a88d 100644
--- a/EFCore/src/Utils/StringBuilderExtensions.cs
+++ b/EFCore/src/Utils/StringBuilderExtensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/src/ValueGeneration/Internal/MySQLValueGeneratorSelector.cs b/EFCore/src/ValueGeneration/Internal/MySQLValueGeneratorSelector.cs
index a991c381d..81137081b 100644
--- a/EFCore/src/ValueGeneration/Internal/MySQLValueGeneratorSelector.cs
+++ b/EFCore/src/ValueGeneration/Internal/MySQLValueGeneratorSelector.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -52,7 +52,23 @@ public MySQLValueGeneratorSelector(
}
+ #if NET8_0_OR_GREATER
///
+ public ValueGenerator Create(IProperty property, IEntityType entityType)
+ {
+ Check.NotNull(property, nameof(property));
+ Check.NotNull(entityType, nameof(entityType));
+
+ var ret = property.ClrType.UnwrapNullableType() == typeof(Guid)
+ ? property.ValueGenerated == ValueGenerated.Never
+ || property.GetDefaultValueSql() != null
+ ? (ValueGenerator)new TemporaryGuidValueGenerator()
+ : new SequentialGuidValueGenerator()
+ : base.Create(property, entityType);
+ return ret;
+ }
+#else
+ ///
public override ValueGenerator Create(IProperty property, IEntityType entityType)
{
Check.NotNull(property, nameof(property));
@@ -66,5 +82,6 @@ public override ValueGenerator Create(IProperty property, IEntityType entityType
: base.Create(property, entityType);
return ret;
}
+#endif
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/BasicGuidTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/BasicGuidTests.cs
index c7f13937b..413d83328 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/BasicGuidTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/BasicGuidTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Infrastructure.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
@@ -58,17 +59,17 @@ public void TestEmptyGUID()
context.Database.EnsureCreated();
var filter = new[] { Guid.Empty };
var resultFilter = context.Guidtable.Where(t => filter.Contains(t.Uuid)).ToArray();
- Assert.IsNotNull(resultFilter);
+ Assert.That(resultFilter, Is.Not.Null);
Random rnd = new Random();
var guid = Guid.NewGuid();
var record = new GuidTable { Id = rnd.Next(100), Uuid = guid };
context.Guidtable.Add(record);
context.SaveChanges();
var rows = context.Guidtable.Count();
- Assert.AreEqual(1, rows);
+ Assert.That(rows, Is.EqualTo(1));
filter[0] = guid;
var resultFilter2 = context.Guidtable.Where(t => filter.Contains(t.Uuid)).ToArray();
- Assert.AreEqual(1, resultFilter2.Count());
+ Assert.That(resultFilter2.Count(), Is.EqualTo(1));
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/ConcurrencyTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/ConcurrencyTests.cs
index fcc531c20..feb4024b3 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/ConcurrencyTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/ConcurrencyTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
@@ -42,8 +43,7 @@ public class ConcurrencyTests
public void CanHandleConcurrencyConflicts()
{
var serviceCollection = new ServiceCollection();
- serviceCollection.AddEntityFrameworkMySQL()
- .AddDbContext();
+ serviceCollection.AddEntityFrameworkMySQL().AddDbContext();
var serviceProvider = serviceCollection.BuildServiceProvider();
@@ -52,11 +52,11 @@ public void CanHandleConcurrencyConflicts()
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
- context.People.Add(new Person { Name = "Mike Redman", SocialSecurityNumber = "SSS1229932", PhoneNumber = "565665656" });
+ context.People.Add(new Person { Name = "John Doe", PersonNumber = "3333333333", PhoneNumber = "1111111111" });
context.SaveChanges();
var person = context.People.Single(p => p.PersonId == 1);
- person.SocialSecurityNumber = "SS15555";
+ person.PersonNumber = "4444444444";
context.Database.ExecuteSqlInterpolated($"UPDATE People SET Name = 'Jane' WHERE PersonId = 1");
@@ -83,7 +83,7 @@ public void CanHandleConcurrencyConflicts()
var originalValue = entry.Property(property.Name).OriginalValue;
var databaseValue = databaseEntry.Property(property.Name).CurrentValue;
entry.Property(property.Name).OriginalValue = databaseEntry.Property(property.Name).CurrentValue;
- Assert.AreEqual("Jane", databaseValue);
+ Assert.That(databaseValue, Is.EqualTo("Jane"));
}
}
}
@@ -102,5 +102,91 @@ public void CanHandleConcurrencyConflicts()
}
}
}
+
+ [Test]
+ public void CanHandleUpdateConcurrencyConflicts()
+ {
+ var serviceCollection = new ServiceCollection();
+ serviceCollection.AddEntityFrameworkMySQL().AddDbContext();
+
+ var serviceProvider = serviceCollection.BuildServiceProvider();
+
+ using (var context = serviceProvider.GetRequiredService())
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+
+ context.People.Add(new Person
+ { Name = "John Doe", PersonNumber = "3333333333", PhoneNumber = "1111111111" });
+ context.SaveChanges();
+
+ var updatePerson1 = context.People.Single(p => p.PersonId == 1);
+ var updatePerson2 = context.People.Single(p => p.PersonId == 1);
+
+ updatePerson1.PersonNumber = "2222222222";
+ updatePerson1.PhoneNumber = "555555555";
+
+ context.SaveChanges();
+
+ var item = context.ChangeTracker.Entries().First(x => Object.ReferenceEquals(x.Entity, updatePerson2));
+ item.OriginalValues["PersonNumber"] = "3333333333";
+ updatePerson2.PersonNumber = "44444444";
+ updatePerson2.PhoneNumber = "666666666";
+
+ TestDelegate action = () => context.SaveChanges();
+ Assert.Throws(action);
+ }
+ }
+
+ [Test]
+ public void CanHandleDeleteConcurrencyConflicts()
+ {
+ var serviceCollection = new ServiceCollection();
+ serviceCollection.AddEntityFrameworkMySQL().AddDbContext();
+
+ var serviceProvider = serviceCollection.BuildServiceProvider();
+
+ using (var context = serviceProvider.GetRequiredService())
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+ context.Remove(new Person { PersonId = 2 , PersonNumber = "88888888" });
+
+ TestDelegate action = () => context.SaveChanges();
+ Assert.Throws(action);
+ }
+ }
+
+ [Test]
+ public void CanHandleInsertConcurrencyConflicts()
+ {
+ var serviceCollection = new ServiceCollection();
+ serviceCollection.AddEntityFrameworkMySQL().AddDbContext();
+
+ var serviceProvider = serviceCollection.BuildServiceProvider();
+
+ using (var context = serviceProvider.GetRequiredService())
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+ context.People.Add(new Person
+ { Name = "John Doe", PersonNumber = "3333333333", PhoneNumber = "1111111111" });
+ context.SaveChanges();
+
+ var insertedPerson1 = context.People.Single(p => p.PersonId == 1);
+ insertedPerson1.PersonNumber = "1111111111";
+
+ context.SaveChanges();
+
+ var item = context.ChangeTracker.Entries().First(x => Object.ReferenceEquals(x.Entity, insertedPerson1));
+ item.OriginalValues["PersonNumber"] = "3333333333";
+
+ context.People.Add(new Person
+ { Name = "John Doe", PersonNumber = "3333333333", PhoneNumber = "1111111111" });
+
+ TestDelegate action = () => context.SaveChanges();
+ Assert.Throws(action);
+ }
+ }
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/ConnectionTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/ConnectionTests.cs
index cfa678fe6..ef30d7d57 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/ConnectionTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/ConnectionTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -40,6 +40,7 @@
using MySql.EntityFrameworkCore.Internal;
using MySql.EntityFrameworkCore.Storage.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System.Diagnostics;
namespace MySql.EntityFrameworkCore.Basic.Tests
@@ -84,7 +85,7 @@ public static RelationalConnectionDependencies CreateDependencies(DbContextOptio
TestServiceFactory.Instance.Create(),
new MySQLOptions()))));
}
-#elif NET7_0 || NET8_0
+#elif NET8_0 || NET9_0
public static RelationalConnectionDependencies CreateDependencies(DbContextOptions? options = null)
{
options ??= new DbContextOptionsBuilder()
@@ -115,6 +116,38 @@ public static RelationalConnectionDependencies CreateDependencies(DbContextOptio
TestServiceFactory.Instance.Create(),
new MySQLOptions()), new ExceptionDetector())));
}
+#elif NET10_0_OR_GREATER
+ public static RelationalConnectionDependencies CreateDependencies(DbContextOptions? options = null)
+ {
+ options ??= new DbContextOptionsBuilder()
+ .UseMySQL(MySQLTestStore.BaseConnectionString + "database=test;")
+ .Options;
+
+ return new RelationalConnectionDependencies(
+ options,
+ new DiagnosticsLogger(
+ new LoggerFactory(),
+ new LoggingOptions(),
+ new DiagnosticListener("FakeDiagnosticListener"),
+ new MySQLLoggingDefinitions(), new NullDbContextLogger()),
+ new RelationalConnectionDiagnosticsLogger(
+ new LoggerFactory(),
+ new LoggingOptions(),
+ new DiagnosticListener("FakeDiagnosticListener"),
+ new TestRelationalLoggingDefinitions(),
+ new NullDbContextLogger(),
+ CreateOptions()),
+ new NamedConnectionStringResolver(options),
+ new RelationalTransactionFactory(new RelationalTransactionFactoryDependencies(
+ new RelationalSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()))),
+ new CurrentDbContext(new FakeDbContext()),
+ new RelationalCommandBuilderFactory(new RelationalCommandBuilderDependencies(
+ new MySQLTypeMappingSource(
+ TestServiceFactory.Instance.Create(),
+ TestServiceFactory.Instance.Create(),
+ new MySQLOptions()), new ExceptionDetector(), new LoggingOptions())),
+ new ExceptionDetector());
+ }
#endif
@@ -136,7 +169,7 @@ public void CanCreateConnectionString()
{
using (var connection = CreateConnection(CreateOptions()))
{
- Assert.IsInstanceOf(connection.DbConnection);
+ Assert.That(connection.DbConnection, Is.InstanceOf());
}
}
@@ -149,10 +182,10 @@ public void CanCreateMainConnection()
{
var csb = new MySqlConnectionStringBuilder(source.ConnectionString);
var csb1 = new MySqlConnectionStringBuilder(MySQLTestStore.BaseConnectionString);
- Assert.True(csb.Database == csb1.Database);
- Assert.True(csb.Port == csb1.Port);
- Assert.True(csb.Server == csb1.Server);
- Assert.True(csb.UserID == csb1.UserID);
+ Assert.That(csb.Database, Is.EqualTo(csb1.Database));
+ Assert.That(csb.Port, Is.EqualTo(csb1.Port));
+ Assert.That(csb.Server, Is.EqualTo(csb1.Server));
+ Assert.That(csb.UserID, Is.EqualTo(csb1.UserID));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DataTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DataTests.cs
index 8dc267629..c8c9f227e 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DataTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DataTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.Data.MySqlClient;
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
using System.Threading.Tasks;
@@ -67,17 +68,17 @@ public async Task AsyncData()
var result = context.SaveChangesAsync();
result.Wait(30_000);
- Assert.IsNull(result.Exception);
- Assert.AreEqual(4, result.Result);
+ Assert.That(result.Exception, Is.Null);
+ Assert.That(result.Result, Is.EqualTo(4));
}
using (var context = new WorldContext())
{
var continent = await context.FindAsync("AS");
- Assert.AreEqual("Asia", continent!.Name);
+ Assert.That(continent!.Name, Is.EqualTo("Asia"));
var continents = await context.Continents.ToListAsync();
- Assert.AreEqual(4, continents.Count);
+ Assert.That(continents.Count, Is.EqualTo(4));
}
}
@@ -93,10 +94,10 @@ public void ZeroDatetime()
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
- Assert.AreEqual(1, context.Database.ExecuteSqlInterpolated($"INSERT IGNORE INTO MyTest (`Date`) VALUES('0000-00-00')"));
+ Assert.That(context.Database.ExecuteSqlInterpolated($"INSERT IGNORE INTO MyTest (`Date`) VALUES('0000-00-00')"), Is.EqualTo(1));
var item = context.MyTest.First();
- Assert.AreEqual(DateTime.MinValue, item.Date);
+ Assert.That(item.Date, Is.EqualTo(DateTime.MinValue));
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/ConventionsContexts.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/ConventionsContexts.cs
index 1efda8333..c5f089188 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/ConventionsContexts.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/ConventionsContexts.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EFFluentAPIContexts.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EFFluentAPIContexts.cs
index 1bc3deca8..ea30b2019 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EFFluentAPIContexts.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EFFluentAPIContexts.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -27,6 +27,7 @@
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using System;
@@ -151,8 +152,7 @@ public class ConcurrencyTestsContext : MyTestContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
- .Property(p => p.SocialSecurityNumber)
- .IsConcurrencyToken();
+ .Property(p => p.PersonNumber).IsConcurrencyToken();
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EntitiesClasses.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EntitiesClasses.cs
index 0f1652c0a..e63c36c4c 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EntitiesClasses.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/EntitiesClasses.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -165,12 +165,26 @@ public class Person
public int PersonId { get; set; }
[ConcurrencyCheck]
- public string? SocialSecurityNumber { get; set; }
+ public string? PersonNumber { get; set; }
public string? PhoneNumber { get; set; }
[ConcurrencyCheck]
public string? Name { get; set; }
}
+ public class Bug35392218_1
+ {
+ public int Id { get; set; }
+
+ public string? Name { get; set; }
+ }
+
+ public class Bug35392218_2
+ {
+ public int Id { get; set; }
+
+ public string? Name { get; set; }
+ }
+
public class Guest
{
[Key]
@@ -225,6 +239,15 @@ public class JsonData
public string? jsoncol { get; set; }
}
+ public partial class AllBlobTypes
+ {
+ public byte Id { get; set; }
+ public byte[]? Example1 { get; set; }
+ public byte[]? Example2 { get; set; }
+ public byte[]? Example3 { get; set; }
+
+ }
+
public partial class AllDataTypes
{
public byte AddressNumber1 { get; set; }
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/SakilaLiteContext.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/SakilaLiteContext.cs
index 0845bcb50..25f240287 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/SakilaLiteContext.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/SakilaLiteContext.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/TestsContexts.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/TestsContexts.cs
index 7ec491f0a..2bed1347e 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/TestsContexts.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbContextClasses/TestsContexts.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -57,6 +57,53 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}
+ public class Bug35392218Context : DbContext
+ {
+ public Bug35392218Context() : base()
+ {
+ }
+
+ public Bug35392218Context(DbContextOptions options) : base(options)
+ {
+ }
+
+ public virtual DbSet NameList { get; set; }
+
+ private string schemaName = "schema_bug35392218_1";
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("bug35392218_table1", "schema_bug35392218_1");
+
+ entity.HasKey(e => e.Id).HasName("id");
+
+ entity.Property(e => e.Name)
+ .HasColumnType("varchar(40)")
+ .HasColumnName("name");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("bug35392218_table2", "schema_bug35392218_2");
+
+ entity.HasKey(e => e.Id).HasName("id");
+
+ entity.Property(e => e.Name)
+ .HasColumnType("varchar(40)")
+ .HasColumnName("name");
+ });
+ }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseMySQL(MySQLTestStore.GetContextConnectionStringWithName(schemaName));
+ }
+ }
+
public class NoConfigurationContext : DbContext
{
public DbSet Blogs { get; set; }
@@ -362,6 +409,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}
+ public partial class AllBlobTypesContext : MyTestContext
+ {
+ public virtual DbSet AllBlobTypes { get; set; }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id)
+ .HasName("PRIMARY");
+
+ entity.ToTable("all_blob_types");
+
+ entity.Property(e => e.Example1)
+ .HasColumnName("blob_column")
+ .HasColumnType("blob");
+
+ entity.Property(e => e.Example2)
+ .HasColumnName("mediumblob_column")
+ .HasColumnType("mediumblob")
+ .HasMaxLength(65535);
+
+ entity.Property(e => e.Example3)
+ .HasColumnName("longblob_column")
+ .HasColumnType("longblob")
+ .HasMaxLength(16777215);
+ });
+ }
+ }
+
public class WorldContext : MyTestContext
{
public virtual DbSet Countries { get; set; }
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/DbFunctionsMySQLTest.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/DbFunctionsMySQLTest.cs
index 88ade0128..645045092 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/DbFunctionsMySQLTest.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/DbFunctionsMySQLTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
@@ -67,7 +68,7 @@ public void DateDiffYear()
var yearsDiff = DateTime.Now.Year - lastUpdate.Year;
var count = context.Actor.Count(a => EF.Functions.DateDiffYear(a.LastUpdate, DateTime.Now) > 0);
- Assert.AreEqual(200, count);
+ Assert.That(count, Is.EqualTo(200));
}
}
@@ -80,7 +81,7 @@ public void DateDiffMonth()
var count = context.Actor
.Count(a => EF.Functions.DateDiffMonth(a.LastUpdate, DateTime.Now) >= monthsDiff - 1);
- Assert.AreEqual(200, count);
+ Assert.That(count, Is.EqualTo(200));
}
}
@@ -93,7 +94,7 @@ public void DateDiffDay()
var count = context.Actor
.Count(a => EF.Functions.DateDiffDay(a.LastUpdate, DateTime.Now) == daysDiff);
- Assert.AreEqual(200, count, "TotalDays: " + daysDiff);
+ Assert.That(count, Is.EqualTo(200), "TotalDays: " + daysDiff);
}
}
@@ -106,7 +107,7 @@ public void DateDiffHour()
var count = context.Actor
.Count(a => EF.Functions.DateDiffHour(a.LastUpdate, DateTime.Now) == hoursDiff);
- Assert.AreEqual(200, count, "TotalHours: " + hoursDiff);
+ Assert.That(count, Is.EqualTo(200), "TotalHours: " + hoursDiff);
}
}
@@ -119,7 +120,7 @@ public void DateDiffMinute()
var count = context.Actor
.Count(a => EF.Functions.DateDiffMinute(a.LastUpdate, DateTime.Now) == minutesDiff);
- Assert.AreEqual(200, count, "TotalMinutes: " + minutesDiff);
+ Assert.That(count, Is.EqualTo(200), "TotalMinutes: " + minutesDiff);
}
}
@@ -132,7 +133,7 @@ public void DateDiffSecond()
var count = context.Actor
.Count(a => EF.Functions.DateDiffSecond(a.LastUpdate, DateTime.Now) >= secondsDiff);
- Assert.AreEqual(200, count, "TotalSeconds: " + secondsDiff);
+ Assert.That(count, Is.EqualTo(200), "TotalSeconds: " + secondsDiff);
}
}
@@ -144,7 +145,7 @@ public void DateDiffMicrosecond()
var count = context.Actor
.Count(a => EF.Functions.DateDiffMicrosecond(a.LastUpdate, DateTime.Now) == 0);
- Assert.AreEqual(0, count);
+ Assert.That(count, Is.EqualTo(0));
}
}
@@ -155,7 +156,7 @@ public void LikeIntLiteral()
{
var count = context.Actor.Count(o => EF.Functions.Like(o.ActorId, "%A%"));
- Assert.AreEqual(0, count);
+ Assert.That(count, Is.EqualTo(0));
}
}
@@ -166,7 +167,7 @@ public void LikeDateTimeLiteral()
{
var count = context.Actor.Count(o => EF.Functions.Like(o.LastUpdate, "%A%"));
- Assert.AreEqual(0, count);
+ Assert.That(count, Is.EqualTo(0));
}
}
@@ -177,7 +178,7 @@ public void LikeIntLiteralWithEscape()
{
var count = context.Actor.Count(o => EF.Functions.Like(o.ActorId, "!%", "!"));
- Assert.AreEqual(0, count);
+ Assert.That(count, Is.EqualTo(0));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/EFCoreTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/EFCoreTests.cs
index 5f9ff2254..35a7593a5 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/EFCoreTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/EFCoreTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -50,8 +50,8 @@ public void ExplicitlyCompiledQueries()
using (SakilaLiteContext context = new SakilaLiteContext())
{
var customer = _customerById(context, 9);
- Assert.AreEqual(9, customer.CustomerId);
- Assert.AreEqual("MOORE", customer.LastName);
+ Assert.That(customer.CustomerId, Is.EqualTo(9));
+ Assert.That(customer.LastName, Is.EqualTo("MOORE"));
}
}
@@ -67,14 +67,14 @@ public void GraphNewAndExistingEntities()
context.Attach(actor = new Actor { ActorId = 21, FirstName = "KIRSTEN", LastName = "PALTROW" });
var changes = context.ChangeTracker.Entries();
- Assert.AreEqual(2, changes.Count());
+ Assert.That(changes.Count(), Is.EqualTo(2));
Assert.That(changes.Select(c => c.State), Has.Exactly(1).Matches(state => state.Equals(EntityState.Added)));
Assert.That(changes.Select(c => c.State), Has.Exactly(1).Matches(state => state.Equals(EntityState.Unchanged)));
context.SaveChanges();
var list = context.Actor.ToList();
- Assert.AreEqual(1, list.Count);
+ Assert.That(list.Count, Is.EqualTo(1));
}
}
@@ -92,8 +92,8 @@ public void StringInterpolationInSqlCommands()
context.Database.ExecuteSqlInterpolated($"INSERT INTO actor(actor_id, first_name, last_name, last_update) VALUES ({id}, {firstName}, {lastName}, {lastUpdate:u})");
Actor actor = context.Set().FromSqlInterpolated($"SELECT * FROM actor WHERE actor_id={id} and last_name={lastName}").First();
- Assert.AreEqual(id, actor.ActorId);
- Assert.AreEqual(firstName, actor.FirstName);
+ Assert.That(actor.ActorId, Is.EqualTo(id));
+ Assert.That(actor.FirstName, Is.EqualTo(firstName));
}
}
@@ -155,7 +155,7 @@ public void QueryWithDate()
&& w.LastUpdate >= DateTime.Today.AddDays(-15));
var res = scenario1.Count();
- Assert.AreEqual(0, res);
+ Assert.That(res, Is.EqualTo(0));
var dt = DateTime.Today.AddDays(-15);
var scenario2 = context.Actor.Where(
@@ -164,7 +164,7 @@ public void QueryWithDate()
&& w.LastUpdate >= dt);
var res2 = scenario2.Count();
- Assert.AreEqual(0, res2);
+ Assert.That(res2, Is.EqualTo(0));
var scenario3 = context.Actor.Where(
w => w.FirstName == "GARY"
@@ -172,7 +172,7 @@ public void QueryWithDate()
&& w.LastUpdate >= DateTime.Today.AddDays(3));
var res3 = scenario3.Count();
- Assert.AreEqual(0, res3);
+ Assert.That(res3, Is.EqualTo(0));
}
}
@@ -200,5 +200,97 @@ public void DateTimeEqualityCheck()
Assert.That(test.Count, Is.EqualTo(1));
}
}
+
+ ///
+ /// Bug#35392218 [bugfix schema name (specially usefull when use multiple schema..]
+ ///
+ [Test]
+ public void MultipleSchemaContext()
+ {
+ try
+ {
+ using (Bug35392218Context context = new Bug35392218Context())
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+
+ context.Add(new Bug35392218_1 { Id = 1, Name = "John Doe" });
+ context.Add(new Bug35392218_2 { Id = 1, Name = "John Doe" });
+ context.SaveChanges();
+
+ using (MySqlConnection connection = new MySqlConnection(MySQLTestStore.BaseConnectionString))
+ {
+ connection.Open();
+
+ MySqlCommand command = connection.CreateCommand();
+ command.CommandText = "SHOW DATABASES LIKE '%bug35392218%';";
+
+ MySqlDataReader reader = command.ExecuteReader();
+ int rowCount = 0;
+ while (reader.Read())
+ {
+ rowCount++;
+ }
+
+ //Checking if 2 databases related to the bug number are created in the server;
+ Assert.That(rowCount, Is.EqualTo(2));
+ reader.Close();
+ }
+
+ using (MySqlConnection connection = new MySqlConnection(MySQLTestStore.BaseConnectionString + "database=schema_bug35392218_1;"))
+ {
+ connection.Open();
+
+ MySqlCommand command = connection.CreateCommand();
+ command.CommandText = "SELECT * FROM bug35392218_table1";
+
+ MySqlDataReader reader = command.ExecuteReader();
+ int rowCount = 0;
+ while (reader.Read())
+ {
+ rowCount++;
+ }
+
+ //Checking if the data is available in 'schemaBug35392218_1' as its the default database definded in the context configuration.
+ Assert.That(rowCount, Is.EqualTo(1));
+ Assert.That(reader.GetString(1), Is.EqualTo("John Doe"));
+
+ reader.Close();
+ }
+
+ using (MySqlConnection connection = new MySqlConnection(MySQLTestStore.BaseConnectionString + "database=schema_bug35392218_2;"))
+ {
+ connection.Open();
+
+ MySqlCommand command = connection.CreateCommand();
+ command.CommandText = "SELECT * FROM bug35392218_table2";
+
+ MySqlDataReader reader = command.ExecuteReader();
+ int rowCount = 0;
+ while (reader.Read())
+ {
+ rowCount++;
+ }
+
+ //Checking if the same data is also inserted into 'schemaBug35392218_2' which is the other database defined in model creation.
+ Assert.That(rowCount, Is.EqualTo(1));
+ Assert.That(reader.GetString(1), Is.EqualTo("John Doe"));
+
+ reader.Close();
+ }
+ }
+ }
+ finally
+ {
+ using (MySqlConnection connection = new MySqlConnection(MySQLTestStore.BaseConnectionString))
+ {
+ connection.Open();
+
+ MySqlCommand command = connection.CreateCommand();
+ command.CommandText = "DROP DATABASE IF EXISTS schema_bug35392218_2;DROP DATABASE IF EXISTS schema_bug35392218_1;";
+ command.ExecuteNonQuery();
+ }
+ }
+ }
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/FluentAPITests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/FluentAPITests.cs
index e36acc2e7..37c27ffbb 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/FluentAPITests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/FluentAPITests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -33,6 +33,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
using System.Text.RegularExpressions;
@@ -56,10 +57,7 @@ public void OneTimeTearDown()
[Test]
public void EnsureRelationalPatterns()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -75,7 +73,7 @@ public void EnsureRelationalPatterns()
context.Employees.Add(e);
context.SaveChanges();
var employeeComputedColumn = context.Employees.FirstOrDefault();
- Assert.True(employeeComputedColumn!.DisplayName!.Equals("Stuart Jos"), "Wrong computed column");
+ Assert.That(employeeComputedColumn!.DisplayName!.Equals("Stuart Jos"), "Wrong computed column");
context.Database.EnsureDeleted();
}
}
@@ -100,7 +98,7 @@ public void CanUseModelWithDateTimeOffset()
context.QuickEntity.Add(e);
context.SaveChanges();
var row = context.QuickEntity.FirstOrDefault();
- Assert.AreEqual(dt, row!.Created);
+ Assert.That(row!.Created, Is.EqualTo(dt));
}
finally
{
@@ -129,7 +127,7 @@ public async Task CanUseModelWithDateTimeOffsetAsync()
context.QuickEntity.Add(e);
context.SaveChanges();
var result = await context.QuickEntity.FirstOrDefaultAsync();
- Assert.AreEqual(dt, result!.Created);
+ Assert.That(result!.Created, Is.EqualTo(dt));
}
catch (Exception)
{
@@ -163,7 +161,7 @@ public void CanNameAlternateKey()
var reader = cmd.ExecuteReader();
while (reader.Read())
{
- Assert.True(reader.GetString(1).ToString().Equals("AlternateKey_LicensePlate"), "Wrong index creation");
+ Assert.That(reader.GetString(1).ToString().Equals("AlternateKey_LicensePlate"), "Wrong index creation");
}
}
}
@@ -188,7 +186,7 @@ public void CanUseToTable()
var reader = cmd.ExecuteReader();
while (reader.Read())
{
- Assert.True(reader.GetString(0).ToString().Equals("somecars"), "Wrong table name");
+ Assert.That(reader.GetString(0).ToString().Equals("somecars"), "Wrong table name");
}
}
context.Database.EnsureDeleted();
@@ -215,7 +213,7 @@ public void CanUseConcurrency()
var reader = cmd.ExecuteReader();
while (reader.Read())
{
- Assert.True(reader.GetString(0).ToString().Equals("somecars"), "Wrong table name");
+ Assert.That(reader.GetString(0).ToString().Equals("somecars"), "Wrong table name");
}
}
context.Database.EnsureDeleted();
@@ -226,10 +224,7 @@ public void CanUseConcurrency()
[Test]
public void CanUseConcurrencyToken()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -246,7 +241,7 @@ public void CanUseConcurrencyToken()
context.Employees.Add(e);
context.SaveChanges();
var employeeComputedColumn = context.Employees.SingleOrDefault();
- Assert.True(employeeComputedColumn!.DisplayName!.Equals("Stuart Jos"), "Wrong computed column");
+ Assert.That(employeeComputedColumn!.DisplayName!.Equals("Stuart Jos"), "Wrong computed column");
context.Database.EnsureDeleted();
}
}
@@ -255,10 +250,7 @@ public void CanUseConcurrencyToken()
[Test]
public void CanUseContainsInQuery()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -282,10 +274,7 @@ public void CanUseContainsInQuery()
[Test]
public void CanUseContainsVarInQuery()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -310,10 +299,7 @@ public void CanUseContainsVarInQuery()
[Test]
public void CanUseContainsWithInvalidValue()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -328,9 +314,9 @@ public void CanUseContainsWithInvalidValue()
context.Employees.Add(e);
context.SaveChanges();
var result = context.Employees.Where(t => t.FirstName!.Contains("XXXXXXXX$%^&*()!")).ToList();
- Assert.IsEmpty(result);
+ Assert.That(result, Is.Empty);
result = context.Employees.Where(t => t.FirstName!.Contains("null")).ToList();
- Assert.IsEmpty(result);
+ Assert.That(result, Is.Empty);
context.Database.EnsureDeleted();
}
}
@@ -339,10 +325,7 @@ public void CanUseContainsWithInvalidValue()
[Test]
public void CanUseContainsWithVariableInQuery()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkMySQL()
@@ -377,10 +360,10 @@ public void TableAttributeTest()
MySqlCommand cmd = new MySqlCommand("SHOW TABLES", conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
- Assert.True(reader.Read());
- StringAssert.AreEqualIgnoringCase("continentlist", reader.GetString(0));
- Assert.True(reader.Read());
- StringAssert.AreEqualIgnoringCase("countrylist", reader.GetString(0));
+ Assert.That(reader.Read());
+ Assert.That(reader.GetString(0), Is.EqualTo("continentlist").IgnoreCase);
+ Assert.That(reader.Read());
+ Assert.That(reader.GetString(0), Is.EqualTo("countrylist").IgnoreCase);
}
}
@@ -406,7 +389,7 @@ public void CharsetTest()
string createTable = reader.GetString(1);
createTable = Regex.Replace(createTable, @"\t|\n|\r", string.Empty);
string txt = "CREATE TABLE `testcharsetda` ( `TestCharsetDAId` varbinary(255) NOT NULL, PRIMARY KEY (`TestCharsetDAId`)) ENGINE=InnoDB DEFAULT CHARSET=ascii";
- StringAssert.AreEqualIgnoringCase(txt, createTable);
+ Assert.That(createTable, Is.EqualTo(txt).IgnoreCase);
}
cmd.CommandText = "SHOW CREATE TABLE `TestCharsetFA`";
@@ -421,12 +404,12 @@ public void CharsetTest()
if (createTable.Contains("COLLATE latin7_general_ci"))
{
txt = "CREATE TABLE `testcharsetfa` ( `TestCharsetFAId` varchar(255) CHARACTER SET latin7 COLLATE latin7_general_ci NOT NULL, PRIMARY KEY (`TestCharsetFAId`)) ENGINE=InnoDB DEFAULT CHARSET=utf16";
- StringAssert.AreEqualIgnoringCase(txt, createTable);
+ Assert.That(createTable, Is.EqualTo(txt).IgnoreCase);
}
else
{
txt = "CREATE TABLE `testcharsetfa` ( `TestCharsetFAId` varchar(255) CHARACTER SET latin7 NOT NULL, PRIMARY KEY (`TestCharsetFAId`)) ENGINE=InnoDB DEFAULT CHARSET=utf16";
- StringAssert.AreEqualIgnoringCase(txt, createTable);
+ Assert.That(createTable, Is.EqualTo(txt).IgnoreCase);
}
}
@@ -437,7 +420,7 @@ public void CharsetTest()
string createTable = reader.GetString(1);
createTable = Regex.Replace(createTable, @"\t|\n|\r", string.Empty);
string txt = "CREATE TABLE `testcollationda` ( `TestCollationDAId` varchar(255) CHARACTER SET greek COLLATE greek_bin NOT NULL, PRIMARY KEY (`TestCollationDAId`)) ENGINE=InnoDB DEFAULT CHARSET=cp932 COLLATE=cp932_bin";
- StringAssert.AreEqualIgnoringCase(txt, createTable);
+ Assert.That(createTable, Is.EqualTo(txt).IgnoreCase);
}
cmd.CommandText = "SHOW CREATE TABLE `TestCollationFA`";
@@ -447,7 +430,7 @@ public void CharsetTest()
string createTable = reader.GetString(1);
createTable = Regex.Replace(createTable, @"\t|\n|\r", string.Empty);
string txt = "CREATE TABLE `testcollationfa` ( `TestCollationFAId` varchar(255) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL, PRIMARY KEY (`TestCollationFAId`)) ENGINE=InnoDB DEFAULT CHARSET=koi8u COLLATE=koi8u_bin";
- StringAssert.AreEqualIgnoringCase(txt, createTable);
+ Assert.That(createTable, Is.EqualTo(txt).IgnoreCase);
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/FunctionalTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/FunctionalTests.cs
index 841407edc..b12e73b80 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/FunctionalTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/FunctionalTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
@@ -61,7 +62,7 @@ public void CanConnectWithConnectionOnConfiguring()
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
- Assert.True(context.Posts.Count() == 0);
+ Assert.That(context.Posts.Count(), Is.EqualTo(0));
context.Database.EnsureDeleted();
}
}
@@ -78,7 +79,7 @@ public void CanThrowExceptionWhenNoConfiguration()
using (var context = serviceProvider.GetRequiredService())
{
- Assert.AreEqual(CoreStrings.NoProviderConfigured, Assert.Throws(() => context.Blogs.Any())!.Message);
+ Assert.That(Assert.Throws(() => context.Blogs.Any())!.Message, Is.EqualTo(CoreStrings.NoProviderConfigured));
}
}
@@ -103,7 +104,7 @@ public void CreatedDb()
var reader = cmd.ExecuteReader();
while (reader.Read())
{
- Assert.True(string.Equals(dbname, reader.GetString(0), StringComparison.CurrentCultureIgnoreCase), "Database was not created");
+ Assert.That(string.Equals(dbname, reader.GetString(0), StringComparison.CurrentCultureIgnoreCase), "Database was not created");
}
}
context.Database.EnsureDeleted();
@@ -131,7 +132,7 @@ public void EnsureRelationalPatterns()
var reader = cmd.ExecuteReader();
while (reader.Read())
{
- Assert.True(string.Equals(dbname, reader.GetString(0), StringComparison.CurrentCultureIgnoreCase), "Database was not created");
+ Assert.That(string.Equals(dbname, reader.GetString(0), StringComparison.CurrentCultureIgnoreCase), "Database was not created");
}
}
context.Database.EnsureDeleted();
@@ -151,8 +152,8 @@ public void CanUseIgnoreEntity()
using (var context = serviceProvider.GetRequiredService())
{
context.Database.EnsureCreated();
- Assert.True(context.Model.GetEntityTypes().Count() == 2, "Wrong model generation");
- Assert.True(context.Blogs.ToList().Count == 0, "");
+ Assert.That(context.Model.GetEntityTypes().Count(), Is.EqualTo(2), "Wrong model generation");
+ Assert.That(context.Blogs.ToList().Count, Is.EqualTo(0), "");
context.Database.EnsureDeleted();
}
}
@@ -166,7 +167,7 @@ public void CanUseOptionsInDbContextCtor()
new MySqlConnection(MySQLTestStore.CreateConnectionString("db-optionsindbcontext"))))
{
context.Database.EnsureCreated();
- Assert.True(context.Blogs.Count() == 0);
+ Assert.That(context.Blogs.Count(), Is.EqualTo(0));
context.Database.EnsureDeleted();
}
@@ -204,11 +205,11 @@ public OptionsContext(DbContextOptions options, MySqlConnection connection)
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
- Assert.AreSame(_options, optionsBuilder.Options);
+ Assert.That(optionsBuilder.Options, Is.SameAs(_options));
optionsBuilder.UseMySQL(_connection);
- Assert.AreNotSame(_options, optionsBuilder.Options);
+ Assert.That(optionsBuilder.Options, Is.Not.SameAs(_options));
}
public override void Dispose()
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/LoadingRelatedDataTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/LoadingRelatedDataTests.cs
index d122a91f6..c73eb25c1 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/LoadingRelatedDataTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/LoadingRelatedDataTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System.Linq;
namespace MySql.EntityFrameworkCore.Basic.Tests
@@ -62,7 +63,7 @@ public void OneTimeTearDown()
[Test]
public void CanUseSkipAndTake()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var people
= context.Set()
.Skip(2)
@@ -75,56 +76,56 @@ var people
[Test]
public void CanIncludeAddressData()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var people
= context.Set()
.Include(p => p.Address)
.ToList();
- Assert.AreEqual(4, people.Count);
- Assert.AreEqual(3, people.Count(p => p.Address != null));
+ Assert.That(people.Count, Is.EqualTo(4));
+ Assert.That(people.Count(p => p.Address != null), Is.EqualTo(3));
}
[Test]
public void CanIncludeGuestData()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var ad
= context.Set()
.Include(p => p.Guest)
.ToList();
- Assert.AreEqual(3, ad.Count);
+ Assert.That(ad.Count, Is.EqualTo(3));
var rows = ad.Select(g => g.Guest).Where(a => a != null).ToList();
- Assert.AreEqual(3, rows.Count());
+ Assert.That(rows.Count(), Is.EqualTo(3));
}
[Test]
public void CanIncludeGuestShadowProperty()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var addressRelative
= context.Set()
.Include(a => a.Relative)
.ToList();
- Assert.AreEqual(3, addressRelative.Count);
- Assert.True(addressRelative.All(p => p.Relative != null));
+ Assert.That(addressRelative.Count, Is.EqualTo(3));
+ Assert.That(addressRelative.All(p => p.Relative != null));
}
[Test]
public void MixClientServerEvaluation()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var list
= context.Set()
.OrderByDescending(a => a.City)
.Select(a => new { Id = a.IdAddress, City = SetCity(a.City!) })
.ToList();
- Assert.AreEqual(3, list.Count);
- StringAssert.EndsWith(" city", list.First().City);
+ Assert.That(list.Count, Is.EqualTo(3));
+ Assert.That(list.First().City, Does.EndWith(" city"));
}
private static string SetCity(string name)
@@ -135,16 +136,16 @@ private static string SetCity(string name)
[Test]
public void RawSqlQueries()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var guests = context.Set().FromSqlRaw("SELECT * FROM Guests")
.ToList();
- Assert.AreEqual(4, guests.Count);
+ Assert.That(guests.Count, Is.EqualTo(4));
}
[Test]
public void UsingTransactions()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
using (var transaction = context.Database.BeginTransaction())
{
context.Set().Add(new Guest()
@@ -153,25 +154,22 @@ public void UsingTransactions()
});
context.SaveChanges();
}
- Assert.AreEqual(4, context.Set().Count());
+ Assert.That(context.Set().Count(), Is.EqualTo(4));
}
[Test]
public void DbSetFind()
{
var address = context.Set().Find(1);
- Assert.NotNull(address);
- Assert.AreEqual("Michigan", address!.City);
+ Assert.That(address, Is.Not.Null);
+ Assert.That(address!.City, Is.EqualTo("Michigan"));
}
[Test]
public void JsonDataTest()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
using (JsonContext context = new JsonContext())
{
@@ -198,10 +196,10 @@ public void JsonDataTest()
}
//Adding "COLLATION" to the string validation at table creation (this happens since MySql 8.0.5 Server)
if (jsonTableDesc.Contains("COLLATE=utf8mb4_0900_ai_ci"))
- StringAssert.AreEqualIgnoringCase($"CREATE TABLE `jsonentity` (\n `Id` smallint{smallintWidth} NOT NULL AUTO_INCREMENT," +
- $"\n `jsoncol` json DEFAULT NULL,\n PRIMARY KEY (`Id`)\n) ENGINE=InnoDB DEFAULT CHARSET={charset} COLLATE=utf8mb4_0900_ai_ci", jsonTableDesc);
- else StringAssert.AreEqualIgnoringCase($"CREATE TABLE `jsonentity` (\n `Id` smallint{smallintWidth} NOT NULL AUTO_INCREMENT,\n `jsoncol` json DEFAULT NULL,\n PRIMARY KEY (`Id`)\n) " +
- $"ENGINE=InnoDB DEFAULT CHARSET={charset}", jsonTableDesc);
+ Assert.That(jsonTableDesc, Is.EqualTo($"CREATE TABLE `jsonentity` (\n `Id` smallint{smallintWidth} NOT NULL AUTO_INCREMENT," +
+ $"\n `jsoncol` json DEFAULT NULL,\n PRIMARY KEY (`Id`)\n) ENGINE=InnoDB DEFAULT CHARSET={charset} COLLATE=utf8mb4_0900_ai_ci").IgnoreCase);
+ else Assert.That(jsonTableDesc, Is.EqualTo($"CREATE TABLE `jsonentity` (\n `Id` smallint{smallintWidth} NOT NULL AUTO_INCREMENT,\n `jsoncol` json DEFAULT NULL,\n PRIMARY KEY (`Id`)\n) " +
+ $"ENGINE=InnoDB DEFAULT CHARSET={charset}").IgnoreCase);
}
context.JsonEntity.Add(new JsonData()
@@ -210,7 +208,7 @@ public void JsonDataTest()
});
context.SaveChanges();
JsonData json = context.JsonEntity.First();
- Assert.AreEqual("{ \"name\": \"Ronald\", \"city\": \"Austin\" }", json.jsoncol);
+ Assert.That(json.jsoncol, Is.EqualTo("{ \"name\": \"Ronald\", \"city\": \"Austin\" }"));
}
}
@@ -218,10 +216,7 @@ public void JsonDataTest()
[Test]
public void JsonInvalidData()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
using (JsonContext context = new JsonContext())
{
@@ -233,7 +228,7 @@ public void JsonInvalidData()
});
var ex = Assert.Throws(() => context.SaveChanges())?.GetBaseException();
- Assert.AreEqual(3140, ((MySqlException)ex!).Number);
+ Assert.That(((MySqlException)ex!).Number, Is.EqualTo(3140));
}
}
@@ -241,10 +236,7 @@ public void JsonInvalidData()
[Test]
public void ComputedColumns()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
using (FiguresContext context = new FiguresContext())
{
@@ -265,8 +257,8 @@ public void ComputedColumns()
context.Triangle.AddRange(data);
context.Triangle.Add(data[1]);
context.SaveChanges();
- Assert.AreEqual(75, data[0].Area);
- Assert.AreEqual(50, data[1].Area);
+ Assert.That(data[0].Area, Is.EqualTo(75));
+ Assert.That(data[1].Area, Is.EqualTo(50));
}
}
@@ -277,12 +269,12 @@ public void ExplicitLoading()
{
context.PopulateData();
var america = context.Continents.Single(c => c.Code == "AM");
- Assert.Null(america.Countries);
+ Assert.That(america.Countries, Is.Null);
context.Entry(america)
.Collection(c => c.Countries!)
.Load();
- Assert.AreEqual(5, america.Countries!.Count);
- Assert.AreEqual("United States", america.Countries.Single(c => c.Code == "US").Name);
+ Assert.That(america.Countries!.Count, Is.EqualTo(5));
+ Assert.That(america.Countries.Single(c => c.Code == "US").Name, Is.EqualTo("United States"));
}
}
@@ -293,7 +285,7 @@ public void ExplicitLoadingQueryingRelatedEntitites()
{
context.PopulateData();
var asia = context.Continents.Single(c => c.Code == "AS");
- Assert.Null(asia.Countries);
+ Assert.That(asia.Countries, Is.Null);
var list = context.Entry(asia)
.Collection(c => c.Countries!)
.Query()
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/ModelingTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/ModelingTests.cs
index 1f696ae53..d20647d7b 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/ModelingTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/ModelingTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -123,10 +124,10 @@ public void LikeFunction()
using (SakilaLiteContext context = new SakilaLiteContext())
{
var query = context.Actor.Where(c => EF.Functions.Like(c.LastName!, "A%")).ToList();
- Assert.IsNotEmpty(query);
+ Assert.That(query, Is.Not.Empty);
foreach (Actor actor in query)
{
- StringAssert.StartsWith("A", actor.LastName);
+ Assert.That(actor.LastName, Does.StartWith("A"));
}
}
}
@@ -157,8 +158,8 @@ public void OwnedEntityTypes()
context.SaveChanges();
var customer = context.Customer.Where(p => p.Address!.AddressId == 1).First();
- Assert.AreEqual(1, customer.CustomerId);
- Assert.AreEqual("47 MySakila Drive", customer.Address!.Address);
+ Assert.That(customer.CustomerId, Is.EqualTo(1));
+ Assert.That(customer.Address!.Address, Is.EqualTo("47 MySakila Drive"));
}
finally
{
@@ -172,8 +173,8 @@ public void ModelLevelQueryFilter()
{
using (SakilaLiteContext context = new SakilaLiteContext())
{
- Assert.AreEqual(584, context.Customer.Count());
- Assert.AreEqual(599, context.Customer.IgnoreQueryFilters().Count());
+ Assert.That(context.Customer.Count(), Is.EqualTo(584));
+ Assert.That(context.Customer.IgnoreQueryFilters().Count(), Is.EqualTo(599));
}
}
@@ -189,12 +190,12 @@ public void ConvertToType()
ls = context.Actor.OrderBy(a => a.ActorId).Select(b => new ActorTest
{
Number = Convert.ToInt32(b.ActorId),
- Value = Convert.ToString(b.LastUpdate),
+ Value = b.LastUpdate.ToString(),
Text = b.FirstName,
}).ToList();
- Assert.IsNotEmpty(ls);
+ Assert.That(ls, Is.Not.Empty);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/MultiSchemaTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/MultiSchemaTests.cs
index 59cba2e4f..8a82615aa 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/MultiSchemaTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/MultiSchemaTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -76,11 +77,11 @@ public void MultiSchemaTest()
{
while (reader.Read())
{
- Assert.Contains(reader.GetString(0), databases);
+ Assert.That(databases.Contains(reader.GetString(0)));
count++;
}
}
- Assert.AreEqual(3, count);
+ Assert.That(count, Is.EqualTo(3));
}
}
}
@@ -136,9 +137,9 @@ public void LoadingData()
});
context.SaveChanges();
- Assert.AreEqual(2, context.Car.Count());
- Assert.AreEqual(2, context.BodyShop.Count());
- Assert.AreEqual(2, context.Employee.Count());
+ Assert.That(context.Car.Count(), Is.EqualTo(2));
+ Assert.That(context.BodyShop.Count(), Is.EqualTo(2));
+ Assert.That(context.Employee.Count(), Is.EqualTo(2));
}
}
@@ -155,4 +156,4 @@ private void PopulateData()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLDatabaseFacadeTest.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLDatabaseFacadeTest.cs
index ffc9a6cb6..1c203cc07 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLDatabaseFacadeTest.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLDatabaseFacadeTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
namespace MySql.EntityFrameworkCore.Basic.Tests
@@ -45,7 +46,7 @@ public void IsMySQLWhenUsingOnConfiguring()
{
using (var context = new MySQLOnConfiguringContext())
{
- Assert.True(context.Database.IsMySql());
+ Assert.That(context.Database.IsMySql());
}
}
@@ -55,7 +56,7 @@ public void IsMySQLInOnModelCreatingWhenUsingOnConfiguring()
using (var context = new MySQLOnModelContext())
{
var _ = context.Model; // Trigger context initialization
- Assert.True(context.IsMySQLSet);
+ Assert.That(context.IsMySQLSet == true);
}
}
@@ -65,7 +66,7 @@ public void IsMySQLInConstructorWhenUsingOnConfiguring()
using (var context = new MySQLConstructorContext())
{
var _ = context.Model; // Trigger context initialization
- Assert.True(context.IsMySQLSet);
+ Assert.That(context.IsMySQLSet == true);
}
}
@@ -74,13 +75,12 @@ public void CannotUseIsMySQLInOnConfiguring()
{
using (var context = new MySQLUseInOnConfiguringContext())
{
- Assert.AreEqual(
- CoreStrings.RecursiveOnConfiguring,
+ Assert.That(
Assert.Throws(
() =>
{
var _ = context.Model; // Trigger context initialization
- })!.Message);
+ })!.Message, Is.EqualTo(CoreStrings.RecursiveOnConfiguring));
}
}
@@ -92,7 +92,7 @@ public void IsMySQLWhenUsingConstructor()
.UseInternalServiceProvider(MySQLFixture.DefaultServiceProvider)
.UseMySQL("Database=Maltesers").Options))
{
- Assert.True(context.Database.IsMySql());
+ Assert.That(context.Database.IsMySql());
}
}
@@ -105,7 +105,7 @@ public void IsMySQLInOnModelCreatingWhenUsingConstructor()
.UseMySQL("Database=Maltesers").Options))
{
var _ = context.Model; // Trigger context initialization
- Assert.True(context.IsMySQLSet);
+ Assert.That(context.IsMySQLSet == true);
}
}
@@ -118,7 +118,7 @@ public void IsMySQLInConstructorWhenUsingConstructor()
.UseMySQL("Database=Maltesers").Options))
{
var _ = context.Model; // Trigger context initialization
- Assert.True(context.IsMySQLSet);
+ Assert.That(context.IsMySQLSet == true);
}
}
@@ -130,13 +130,12 @@ public void CannotUseIsMySQLInOnConfiguringWithConstructor()
.UseInternalServiceProvider(MySQLFixture.DefaultServiceProvider)
.UseMySQL("Database=Maltesers").Options))
{
- Assert.AreEqual(
- CoreStrings.RecursiveOnConfiguring,
+ Assert.That(
Assert.Throws(
() =>
{
var _ = context.Model; // Trigger context initialization
- })!.Message);
+ })!.Message, Is.EqualTo(CoreStrings.RecursiveOnConfiguring));
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLTypeMapperTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLTypeMapperTests.cs
index 5738fc9d3..03a06aac0 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLTypeMapperTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/MySQLTypeMapperTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,6 +31,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -47,15 +48,14 @@ public void OneTimeTearDown()
context.Database.EnsureDeleted();
using (var context = new StringTypesContext())
context.Database.EnsureDeleted();
+ using (var context = new AllBlobTypesContext())
+ context.Database.EnsureDeleted();
}
[Test]
public void InsertAllDataTypes()
{
- if (!TestUtils.IsAtLeast(5, 7, 0))
- {
- Assert.Ignore();
- }
+ Assume.That(TestUtils.IsAtLeast(5, 7, 0));
DateTime now = new DateTime(DateTime.Today.AddSeconds(1).AddMilliseconds(1).AddTicks(10).Ticks);
@@ -100,33 +100,75 @@ public void InsertAllDataTypes()
using (var context = new AllDataTypesContext())
{
var data = context.AllDataTypes.First();
- Assert.AreEqual(1, data.AddressNumber1);
- Assert.AreEqual(2, data.AddressNumber2);
- Assert.AreEqual(3, data.AddressNumber3);
- Assert.AreEqual(4, data.AddressNumber4);
- Assert.AreEqual((long)5, data.AddressNumber5);
- Assert.AreEqual(6.36f, data.AddressNumber6);
- Assert.AreEqual(7.49f, data.AddressNumber7);
- Assert.AreEqual(8.64d, data.AddressNumber8);
- Assert.AreEqual(9.81m, data.AddressNumber9);
- Assert.AreEqual(10, data.AddressNumber10);
- Assert.AreEqual("BuildingName1", data.BuildingName1);
- Assert.AreEqual("BuildingName2", data.BuildingName2);
- Assert.AreEqual("BuildingName3", data.BuildingName3);
- Assert.AreEqual("BuildingName4", data.BuildingName4);
- Assert.AreEqual("BuildingName5", data.BuildingName5);
- Assert.AreEqual("BuildingName6".PadRight(120, '\0'), UTF8Encoding.UTF8.GetString(data.BuildingName6!));
- Assert.AreEqual("BuildingName7", UTF8Encoding.UTF8.GetString(data.BuildingName7!));
- Assert.AreEqual("BuildingName8", UTF8Encoding.UTF8.GetString(data.BuildingName8!));
- Assert.AreEqual("BuildingName9", UTF8Encoding.UTF8.GetString(data.BuildingName9!));
- Assert.AreEqual("BuildingName10", UTF8Encoding.UTF8.GetString(data.BuildingName10!));
- Assert.AreEqual("small", data.BuildingName11);
- Assert.AreEqual("small,medium,large", data.BuildingName12);
- Assert.AreEqual(now.Date, data.BuildingName13);
- Assert.AreEqual(now, data.BuildingName14);
- Assert.AreEqual(now.TimeOfDay, data.BuildingName15);
- Assert.AreEqual(now, data.BuildingName16);
- Assert.AreEqual(now.Year, data.BuildingName17);
+ Assert.That(data.AddressNumber1, Is.EqualTo(1));
+ Assert.That(data.AddressNumber2, Is.EqualTo(2));
+ Assert.That(data.AddressNumber3, Is.EqualTo(3));
+ Assert.That(data.AddressNumber4, Is.EqualTo(4));
+ Assert.That(data.AddressNumber5, Is.EqualTo((long)5));
+ Assert.That(data.AddressNumber6, Is.EqualTo(6.36f));
+ Assert.That(data.AddressNumber7, Is.EqualTo(7.49f));
+ Assert.That(data.AddressNumber8, Is.EqualTo(8.64d));
+ Assert.That(data.AddressNumber9, Is.EqualTo(9.81m));
+ Assert.That(data.AddressNumber10, Is.EqualTo(10));
+ Assert.That(data.BuildingName1, Is.EqualTo("BuildingName1"));
+ Assert.That(data.BuildingName2, Is.EqualTo("BuildingName2"));
+ Assert.That(data.BuildingName3, Is.EqualTo("BuildingName3"));
+ Assert.That(data.BuildingName4, Is.EqualTo("BuildingName4"));
+ Assert.That(data.BuildingName5, Is.EqualTo("BuildingName5"));
+ Assert.That(UTF8Encoding.UTF8.GetString(data.BuildingName6!), Is.EqualTo("BuildingName6".PadRight(120, '\0')));
+ Assert.That(UTF8Encoding.UTF8.GetString(data.BuildingName7!), Is.EqualTo("BuildingName7"));
+ Assert.That(UTF8Encoding.UTF8.GetString(data.BuildingName8!), Is.EqualTo("BuildingName8"));
+ Assert.That(UTF8Encoding.UTF8.GetString(data.BuildingName9!), Is.EqualTo("BuildingName9"));
+ Assert.That(UTF8Encoding.UTF8.GetString(data.BuildingName10!), Is.EqualTo("BuildingName10"));
+ Assert.That(data.BuildingName11, Is.EqualTo("small"));
+ Assert.That(data.BuildingName12, Is.EqualTo("small,medium,large"));
+ Assert.That(data.BuildingName13, Is.EqualTo(now.Date));
+ Assert.That(data.BuildingName14, Is.EqualTo(now));
+ Assert.That(data.BuildingName15, Is.EqualTo(now.TimeOfDay));
+ Assert.That(data.BuildingName16, Is.EqualTo(now));
+ Assert.That(data.BuildingName17, Is.EqualTo(now.Year));
+ }
+ }
+
+ ///
+ /// Bug#36208913 Byte array type mapping has a fixed limit of 8000 in EFCore
+ ///
+ [Test]
+ public void LongBlobMapping()
+ {
+ using (var context = new AllBlobTypesContext())
+ {
+ context.Database.EnsureDeleted();
+ context.Database.EnsureCreated();
+
+
+ var data1 = new byte[7000];
+ var data2 = new byte[60000];
+ var data3 = new byte[90000];
+
+
+ context.AllBlobTypes.Add(new AllBlobTypes()
+ {
+ Id = 1,
+ Example1 = data1,
+ Example2 = data2,
+ Example3 = data3,
+ });
+ context.SaveChanges();
+ }
+
+ using (var context = new AllBlobTypesContext())
+ {
+
+ var data1 = new byte[7000];
+ var data2 = new byte[60000];
+ var data3 = new byte[90000];
+
+ var data = context.AllBlobTypes.First();
+
+ Assert.That(data.Example1.Length, Is.EqualTo(data1.Length));
+ Assert.That(data.Example2.Length, Is.EqualTo(data2.Length));
+ Assert.That(data.Example3.Length, Is.EqualTo(data3.Length));
}
}
@@ -158,10 +200,10 @@ public void ValidateStringLength()
{
string field = reader.GetString("field");
string type = validation[field];
- Assert.AreEqual(type, reader.GetString("type"));
+ Assert.That(reader.GetString("type"), Is.EqualTo(type));
counter++;
}
- Assert.AreEqual(validation.Count, counter);
+ Assert.That(counter, Is.EqualTo(validation.Count));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/MySql.EntityFrameworkCore.Basic.Tests.csproj b/EFCore/tests/MySql.EFCore.Basic.Tests/MySql.EntityFrameworkCore.Basic.Tests.csproj
index 6fb99961f..f3c7b8036 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/MySql.EntityFrameworkCore.Basic.Tests.csproj
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/MySql.EntityFrameworkCore.Basic.Tests.csproj
@@ -2,7 +2,7 @@
MySql.EntityFrameworkCore.Basic.Tests Class Library
- net6.0;net7.0;net8.0;
+ net9.0;net8.0;
MySql.EntityFrameworkCore.Basic.Tests
MySql.EntityFrameworkCore.Basic.Tests
true
@@ -13,22 +13,28 @@
CS1591,CS1701,CS1702,EF1001
-
-
+
+ $(TargetFrameworks);net10.0
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/Properties/DatabaseSetup.sql b/EFCore/tests/MySql.EFCore.Basic.Tests/Properties/DatabaseSetup.sql
index 8f78b919b..6a67848d2 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/Properties/DatabaseSetup.sql
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/Properties/DatabaseSetup.sql
@@ -1,17 +1,17 @@
/*
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -40,4 +40,4 @@ FLUSH PRIVILEGES;
SET GLOBAL max_allowed_packet = 1048576;
-FLUSH PRIVILEGES;
\ No newline at end of file
+FLUSH PRIVILEGES;
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/ShadowPropertiesTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/ShadowPropertiesTests.cs
index 979fe44b8..faf443047 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/ShadowPropertiesTests.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/ShadowPropertiesTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -32,6 +32,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Data;
using System.Linq;
@@ -59,7 +60,7 @@ public ShadowPropertiesTests()
[Test]
public void CanUseShadowPropertyWhenUpdatingEntry()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var ad = new Address { Street = "New street two", City = "Chicago" };
var g = new Guest { Name = "Guest number two", Address = ad };
context.Set().Add(g);
@@ -67,7 +68,7 @@ public void CanUseShadowPropertyWhenUpdatingEntry()
// update entry
var entry = context.Set().Where(t => t.Name!.Equals("Guest number two")).First();
- Assert.False(entry == null);
+ Assert.That(entry, Is.Not.Null);
entry!.Name = "Guest number two updated";
context.SaveChanges();
@@ -80,15 +81,15 @@ public void CanUseShadowPropertyWhenUpdatingEntry()
var cmd = new MySqlCommand("Select UpdatedAt from Guests where IdGuest=" + entry.IdGuest, cnn);
var updatedAt = cmd.ExecuteScalar();
- Assert.False(updatedAt == null);
- Assert.True(((DateTime)updatedAt!).Date.CompareTo(DateTime.Now.Date) == 0);
+ Assert.That(updatedAt, Is.Not.Null);
+ Assert.That(((DateTime)updatedAt!).Date.CompareTo(DateTime.Now.Date) == 0);
}
}
[Test]
public void CanUseShadowPropertyWhenAddingEntry()
{
- Assert.False(context.Database.EnsureCreated());
+ Assert.That(!context.Database.EnsureCreated());
var ad = new Address { Street = "New street", City = "Oregon" };
var g = new Guest { Name = "Guest number one", Address = ad };
context.Set().Add(g);
@@ -103,8 +104,8 @@ public void CanUseShadowPropertyWhenAddingEntry()
var cmd = new MySqlCommand("Select CreatedAt from Guests Limit 1", cnn);
var createdAt = cmd.ExecuteScalar();
- Assert.False(createdAt == null);
- Assert.True(((DateTime)createdAt!).Date.CompareTo(DateTime.Now.Date) == 0);
+ Assert.That(createdAt, Is.Not.Null);
+ Assert.That(((DateTime)createdAt!).Date.CompareTo(DateTime.Now.Date) == 0);
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/UpdateTests.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/UpdateTests.cs
new file mode 100644
index 000000000..0a95d864b
--- /dev/null
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/UpdateTests.cs
@@ -0,0 +1,87 @@
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using Microsoft.EntityFrameworkCore;
+using MySql.EntityFrameworkCore.Basic.Tests.Utils;
+using NUnit.Framework;
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MySql.EntityFrameworkCore.Basic.Tests
+{
+
+#region Bug113443
+
+ [Table("Bug113443Table")]
+ public record Bug113443Record
+ {
+ [Key]
+ [Column("id")]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int Id { get; init; }
+ [Column("name")]
+ public string? Name { get; set;}
+
+ [Column("time_created", TypeName = "TIMESTAMP(6)")]
+ [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
+ public DateTime TimeCreated { get; init; }
+
+ [Column("time_updated", TypeName = "TIMESTAMP(6)")]
+ [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
+ public DateTime TimeUpdated { get; init; }
+ }
+
+ public class Bug113443Context : MyTestContext
+ {
+ public DbSet Bug113443 { get; set; }
+ }
+
+#endregion
+
+ public class UpdateTests
+ {
+ [Test]
+ public void Bug113443() {
+ using var ctx = new Bug113443Context();
+ ctx.Database.EnsureCreated();
+ try
+ {
+ Bug113443Record data = new() { Name = "Sample1"};
+ ctx.Bug113443.Add(data);
+ ctx.SaveChanges();
+ data.Name = "Changed!";
+ ctx.SaveChanges();
+ }
+ finally
+ {
+ ctx.Database.EnsureDeleted();
+ }
+ }
+ }
+}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/EntityTestsFixtureClass.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/EntityTestsFixtureClass.cs
index 5416d7114..2903470fa 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/EntityTestsFixtureClass.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/EntityTestsFixtureClass.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.Data.MySqlClient;
using MySql.EntityFrameworkCore.Basic.Tests.DbContextClasses;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Diagnostics;
using System.Text;
@@ -92,7 +93,7 @@ protected internal void CheckSql(string sql, string refSql)
foreach (char c in refSql)
if (!Char.IsWhiteSpace(c))
str2.Append(c);
- Assert.AreEqual(0, String.Compare(str1.ToString(), str2.ToString(), true));
+ Assert.That(String.Compare(str1.ToString(), str2.ToString(), true), Is.EqualTo(0));
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/MySqlTestStore.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/MySqlTestStore.cs
index 7470d9c30..59b4bf5a7 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/MySqlTestStore.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/MySqlTestStore.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using MySql.EntityFrameworkCore.Infrastructure.Internal;
using System;
using System.Data;
+using System.Data.Common;
namespace MySql.EntityFrameworkCore.Basic.Tests.Utils
{
@@ -88,6 +89,11 @@ internal static string GetContextConnectionString(Type type)
return MySQLTestStore.RootConnectionString + $";database={name};";
}
+ internal static string GetContextConnectionStringWithName(string name)
+ {
+ return MySQLTestStore.RootConnectionString + $";database={name};";
+ }
+
public static string Port()
{
var port = Environment.GetEnvironmentVariable("MYSQL_PORT");
@@ -225,21 +231,42 @@ public static void DeleteDatabase(string name)
public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder)
=> builder.UseMySQL(GetContextConnectionString());
+#if NET9_0_OR_GREATER
+ public virtual void Clean(DbContext context)
+ => context.Database.EnsureDeleted();
+#else
public override void Clean(DbContext context)
=> context.Database.EnsureDeleted();
+#endif
- public static MySQLTestStore Create(string name)
- => new MySQLTestStore(name);
- public static MySQLTestStore GetOrCreate(string name)
- => new MySQLTestStore(name);
+#if NET9_0_OR_GREATER
+ private MySQLTestStore(string name, DbConnection connection)
+ : base(name, true, connection)
+ {
+ SslMode = true;
+ connection = new MySqlConnection(RootConnectionString);
+ }
+ public static MySQLTestStore Create(string name, DbConnection connection)
+ => new MySQLTestStore(name, connection);
+
+ public static MySQLTestStore GetOrCreate(string name, DbConnection connection)
+ => new MySQLTestStore(name, connection);
+#else
private MySQLTestStore(string name)
: base(name, true)
{
SslMode = true;
Connection = new MySqlConnection(RootConnectionString);
}
+
+ public static MySQLTestStore Create(string name)
+ => new MySQLTestStore(name);
+
+ public static MySQLTestStore GetOrCreate(string name)
+ => new MySQLTestStore(name);
+#endif
}
public class MySQLTestStoreFactory : RelationalTestStoreFactory
@@ -250,13 +277,25 @@ protected MySQLTestStoreFactory()
{
}
+#if NET9_0_OR_GREATER
+ public override TestStore Create(string storeName)
+ => MySQLTestStore.Create(storeName, new MySqlConnection(MySQLTestStore.RootConnectionString));
+
+ public override TestStore GetOrCreate(string storeName)
+ => MySQLTestStore.GetOrCreate(storeName, new MySqlConnection(MySQLTestStore.RootConnectionString));
+#else
public override TestStore Create(string storeName)
=> MySQLTestStore.Create(storeName);
public override TestStore GetOrCreate(string storeName)
=> MySQLTestStore.GetOrCreate(storeName);
+#endif
+
+
+
public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection)
=> serviceCollection.AddEntityFrameworkMySQL();
+
}
}
diff --git a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/TestUtils.cs b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/TestUtils.cs
index 5c3b56c3e..7b9b59314 100644
--- a/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/TestUtils.cs
+++ b/EFCore/tests/MySql.EFCore.Basic.Tests/Utils/TestUtils.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/Extensions.cs b/EFCore/tests/MySql.EFCore.Design.Tests/Extensions.cs
index 0ed03a4ff..1543ee7ab 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/Extensions.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/Extensions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLAnnotationCodeGeneratorTest.cs b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLAnnotationCodeGeneratorTest.cs
index 820f6d806..7f0ed3e2a 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLAnnotationCodeGeneratorTest.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLAnnotationCodeGeneratorTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -36,6 +36,7 @@
using MySql.EntityFrameworkCore.Metadata.Internal;
using MySql.EntityFrameworkCore.Storage.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System.Linq;
namespace MySql.EntityFrameworkCore.Design.Tests
@@ -64,8 +65,8 @@ public void GenerateFluentApiHasCharset(string mySQLAnnotation)
var annotation = key?.FindAnnotation(mySQLAnnotation);
var result = MySQLAnnotationCodeGenerator.GenFluentApi((Microsoft.EntityFrameworkCore.Metadata.IProperty)key!, annotation!);
- Assert.AreEqual(mySQLAnnotation == MySQLAnnotationNames.Charset ? "ForMySQLHasCharset" : "ForMySQLHasCollation", result?.Method);
- Assert.AreEqual(1, result?.Arguments.Count);
+ Assert.That(result?.Method, Is.EqualTo(mySQLAnnotation == MySQLAnnotationNames.Charset ? "ForMySQLHasCharset" : "ForMySQLHasCollation"));
+ Assert.That(result?.Arguments.Count, Is.EqualTo(1));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLCodeGeneratorTest.cs b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLCodeGeneratorTest.cs
index a91b2200c..42f3804c9 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLCodeGeneratorTest.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLCodeGeneratorTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -32,6 +32,7 @@
using MySql.EntityFrameworkCore.Infrastructure;
using MySql.EntityFrameworkCore.Scaffolding.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
using System.Reflection;
@@ -49,9 +50,9 @@ public virtual void UseProviderMethodIsGeneratedCorrectly()
var result = codeGenerator.GenerateUseProvider("Data Source=Test", providerOptions: null);
- Assert.AreEqual("UseMySQL", result.Method);
+ Assert.That(result.Method, Is.EqualTo("UseMySQL"));
Assert.That(result.Arguments, Has.Exactly(1).EqualTo("Data Source=Test"));
- Assert.Null(result.ChainedCall);
+ Assert.That(result.ChainedCall, Is.Null);
}
[Test]
@@ -65,13 +66,13 @@ public virtual void UseProviderMethodIsGeneratedCorrectlyWithOptions()
var result = codeGenerator.GenerateUseProvider("Data Source=Test", providerOptions);
- Assert.AreEqual("UseMySQL", result.Method);
+ Assert.That(result.Method, Is.EqualTo("UseMySQL"));
Assert.That(result.Arguments, Has.Exactly(1).EqualTo("Data Source=Test"));
- Assert.IsInstanceOf(result.Arguments[1]);
+ Assert.That(result.Arguments[1], Is.InstanceOf());
NestedClosureCodeFragment nestedClosure = (NestedClosureCodeFragment)result.Arguments[1]!;
- Assert.AreEqual("x", nestedClosure?.Parameter);
- Assert.AreSame(providerOptions, nestedClosure?.MethodCalls[0]);
- Assert.Null(result.ChainedCall);
+ Assert.That(nestedClosure?.Parameter, Is.EqualTo("x"));
+ Assert.That(nestedClosure?.MethodCalls[0], Is.SameAs(providerOptions));
+ Assert.That(result.ChainedCall, Is.Null);
}
private static readonly MethodInfo UseMySqlServerMethodInfo
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFactoryTest.cs b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFactoryTest.cs
index a63741fa9..beb0ab423 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFactoryTest.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFactoryTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -35,6 +35,7 @@
using MySql.EntityFrameworkCore.Diagnostics.Internal;
using MySql.EntityFrameworkCore.Scaffolding.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -101,7 +102,7 @@ PRIMARY KEY (description, id)
Assert.Multiple(() =>
{
- Assert.AreEqual("blogman", dbModel.DatabaseName);
+ Assert.That(dbModel.DatabaseName, Is.EqualTo("blogman"));
Assert.That(dbModel.Tables.Select(c => c.Name), Has.Exactly(1).Matches(table => table.Contains("blogs")));
});
@@ -110,27 +111,27 @@ PRIMARY KEY (description, id)
Assert.That(columns.Where(n => n.Name == "id").Select(a => a.Name), Has.Exactly(1).Matches(name => name.Contains("id")));
Assert.That(columns.Where(n => n.Name == "id").Select(a => a.GetDataType()), Has.One.Items.EqualTo("int" + smallintWidth));
Assert.That(columns.Where(n => n.Name == "id").Select(a => a.GetPrimaryKeyOrdinal(2)), Has.One.Items.EqualTo(2));
- Assert.False(columns.Where(n => n.Name == "id").Select(a => a.IsNullable).FirstOrDefault());
+ Assert.That(!columns.Where(n => n.Name == "id").Select(a => a.IsNullable).FirstOrDefault());
Assert.That(columns.Where(n => n.Name == "id").Select(a => a.GetOrdinal(0)), Has.One.Items.EqualTo(0));
- Assert.IsNull(columns.Where(n => n.Name == "id").Select(a => a.GetDefaultValue()).FirstOrDefault());
+ Assert.That(columns.Where(n => n.Name == "id").Select(a => a.GetDefaultValue()).FirstOrDefault(), Is.Null);
Assert.That(columns.Where(n => n.Name == "description").Select(a => a.Name), Has.Exactly(1).Matches(name => name.Contains("description")));
Assert.That(columns.Where(n => n.Name == "description").Select(a => a.GetDataType()), Has.One.Items.EqualTo("varchar(100)"));
Assert.That(columns.Where(n => n.Name == "description").Select(a => a.GetPrimaryKeyOrdinal(1)), Has.One.Items.EqualTo(1));
- Assert.False(columns.Where(n => n.Name == "description").Select(a => a.IsNullable).FirstOrDefault());
+ Assert.That(!columns.Where(n => n.Name == "description").Select(a => a.IsNullable).FirstOrDefault());
Assert.That(columns.Where(n => n.Name == "description").Select(a => a.GetOrdinal(1)), Has.One.Items.EqualTo(1));
- Assert.IsNull(columns.Where(n => n.Name == "description").Select(a => a.GetDefaultValue()).FirstOrDefault());
+ Assert.That(columns.Where(n => n.Name == "description").Select(a => a.GetDefaultValue()).FirstOrDefault(), Is.Null);
Assert.That(columns.Where(n => n.Name == "description").Select(a => a.GetMaxLength(100)), Has.One.Items.EqualTo(100));
Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.Name), Has.Exactly(1).Matches(name => name.Contains("rate")));
Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetDataType()), Has.One.Items.EqualTo("decimal(5,2)"));
- Assert.IsNull(columns.Where(n => n.Name == "rate").Select(a => a.GetPrimaryKeyOrdinal(null)).FirstOrDefault());
- Assert.True(columns.Where(n => n.Name == "rate").Select(a => a.IsNullable).FirstOrDefault());
+ Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetPrimaryKeyOrdinal(null)).FirstOrDefault(), Is.Null);
+ Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.IsNullable).FirstOrDefault());
Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetOrdinal(2)), Has.One.Items.EqualTo(2));
- StringAssert.AreEqualIgnoringCase(columns.Where(n => n.Name == "rate").Select(a => a.GetDefaultValue()).FirstOrDefault(), "'0.00'");
+ Assert.That("'0.00'", Is.EqualTo(columns.Where(n => n.Name == "rate").Select(a => a.GetDefaultValue()).FirstOrDefault()).IgnoreCase);
Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetPrecision(5)), Has.One.Items.EqualTo(5));
Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetScale(2)), Has.One.Items.EqualTo(2));
- Assert.IsNull(columns.Where(n => n.Name == "rate").Select(a => a.GetMaxLength(null)).FirstOrDefault());
+ Assert.That(columns.Where(n => n.Name == "rate").Select(a => a.GetMaxLength(null)).FirstOrDefault(), Is.Null);
Assert.That(columns.Where(n => n.Name == "created").Select(a => a.Name), Has.Exactly(1).Matches(name => name.Contains("created")));
Assert.That(columns.Where(n => n.Name == "created").Select(a => a.GetDefaultValue()), Has.One.Items.EqualTo("CURRENT_TIMESTAMP"));
@@ -162,14 +163,14 @@ KEY idx_fk_country_id (country_id),
var dbModel = _fixture!.CreateModel("sakiladb", sql, new List { "city", "country" }, new List());
var fk = (dbModel.Tables.Single(t => t.ForeignKeys.Count > 0).ForeignKeys);
- Assert.IsNotNull(fk);
- Assert.AreEqual("sakiladb", fk[0].Table.Database!.DatabaseName);
- Assert.AreEqual("city", fk[0].Table.Name);
- Assert.AreEqual("sakiladb", fk[0].PrincipalTable.Database!.DatabaseName);
- Assert.AreEqual("country", fk[0].PrincipalTable.Name);
- Assert.AreEqual("country_id", fk[0].GetColumn().Name);
- Assert.AreEqual("country_id", fk[0].GetPrincipalColumn().Name);
- Assert.AreEqual(ReferentialAction.Restrict, fk[0].OnDelete);
+ Assert.That(fk, Is.Not.Null);
+ Assert.That(fk[0].Table.Database!.DatabaseName, Is.EqualTo("sakiladb"));
+ Assert.That(fk[0].Table.Name, Is.EqualTo("city"));
+ Assert.That(fk[0].PrincipalTable.Database!.DatabaseName, Is.EqualTo("sakiladb"));
+ Assert.That(fk[0].PrincipalTable.Name, Is.EqualTo("country"));
+ Assert.That(fk[0].GetColumn().Name, Is.EqualTo("country_id"));
+ Assert.That(fk[0].GetPrincipalColumn().Name, Is.EqualTo("country_id"));
+ Assert.That(fk[0].OnDelete, Is.EqualTo(ReferentialAction.Restrict));
}
[Test]
@@ -194,23 +195,23 @@ PRIMARY KEY(actor_id),
Assert.Multiple(() =>
{
var c = indexes[0];
- Assert.AreEqual("sakilaIndex", c.Table!.Database!.DatabaseName);
- Assert.AreEqual("actor", c.Table.Name);
+ Assert.That(c.Table!.Database!.DatabaseName, Is.EqualTo("sakilaIndex"));
+ Assert.That(c.Table.Name, Is.EqualTo("actor"));
});
Assert.Multiple(() =>
{
var composite = indexes[0];
- Assert.AreEqual("idx_actor_first_last_name", composite.Name);
- Assert.False(composite.IsUnique);
- Assert.AreEqual(new List { "first_name", "last_name" }, composite.GetColumns().Select(c => c.GetColumn().Name).ToList());
+ Assert.That(composite.Name, Is.EqualTo("idx_actor_first_last_name"));
+ Assert.That(!composite.IsUnique);
+ Assert.That(composite.GetColumns().Select(c => c.GetColumn().Name).ToList(), Is.EqualTo(new List { "first_name", "last_name" }));
});
Assert.Multiple(() =>
{
var onecolumn = indexes[1];
- Assert.AreEqual("last_name", onecolumn.GetColumn().Name);
- Assert.True(onecolumn.IsUnique);
+ Assert.That(onecolumn.GetColumn().Name, Is.EqualTo("last_name"));
+ Assert.That(onecolumn.IsUnique);
}
);
}
@@ -249,7 +250,7 @@ private void Test(string createSql, IEnumerable tables, IEnumerable tables, IEnumerable { "t1", "x1" };
var dbModel = _fixture!.CreateModel("testview", sql, selectionSet, new List());
- Assert.True(dbModel.Tables.Count == 2);
+ Assert.That(dbModel.Tables.Count == 2);
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFixture.cs b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFixture.cs
index 4cbb4bcda..fc586e967 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFixture.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDatabaseModelFixture.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -75,4 +75,4 @@ public DatabaseModel CreateModel(string dbName, string sql, IEnumerable
new DatabaseModelFactoryOptions(tables, schemas));
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDesignTimeProviderServicesTest.cs b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDesignTimeProviderServicesTest.cs
index beb719f0d..8c30712d7 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDesignTimeProviderServicesTest.cs
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySQLDesignTimeProviderServicesTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,6 +30,7 @@
using MySql.EntityFrameworkCore.Design.Internal;
using MySql.EntityFrameworkCore.Storage.Internal;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Reflection;
@@ -50,9 +51,9 @@ public void EnsureAssemblyIdentityMatches()
var dtAttribute = runtimeAssembly.GetCustomAttribute();
var dtType = GetDesignTimeServicesType();
- Assert.NotNull(dtType);
- Assert.NotNull(dtAttribute);
- Assert.AreEqual(dtType.FullName, dtAttribute?.TypeName);
+ Assert.That(dtType, Is.Not.Null);
+ Assert.That(dtAttribute, Is.Not.Null);
+ Assert.That(dtAttribute?.TypeName, Is.EqualTo(dtType.FullName));
}
}
-}
\ No newline at end of file
+}
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/MySql.EntityFrameworkCore.Design.Tests.csproj b/EFCore/tests/MySql.EFCore.Design.Tests/MySql.EntityFrameworkCore.Design.Tests.csproj
index 7ce9788d5..632c8baa4 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/MySql.EntityFrameworkCore.Design.Tests.csproj
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/MySql.EntityFrameworkCore.Design.Tests.csproj
@@ -2,7 +2,7 @@
MySql.EntityFrameworkCore.Design.Tests Class Library
- net6.0;net7.0;net8.0;
+ net9.0;net8.0;
MySql.EntityFrameworkCore.Design.Tests
MySql.EntityFrameworkCore.Design.Tests
true
@@ -13,6 +13,10 @@
$(NoWarn);CS1591,EF1001
+
+ $(TargetFrameworks);net10.0
+
+
@@ -24,10 +28,21 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/Properties/sakiladb-schema.sql b/EFCore/tests/MySql.EFCore.Design.Tests/Properties/sakiladb-schema.sql
index 72c4e3812..33a025602 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/Properties/sakiladb-schema.sql
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/Properties/sakiladb-schema.sql
@@ -1,17 +1,17 @@
/*
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Design.Tests/Properties/world.sql b/EFCore/tests/MySql.EFCore.Design.Tests/Properties/world.sql
index 6d2e171ec..9374e9c57 100644
--- a/EFCore/tests/MySql.EFCore.Design.Tests/Properties/world.sql
+++ b/EFCore/tests/MySql.EFCore.Design.Tests/Properties/world.sql
@@ -1,17 +1,17 @@
/*
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLHistoryRepositoryTests.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLHistoryRepositoryTests.cs
index 148c3da26..6421977d3 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLHistoryRepositoryTests.cs
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLHistoryRepositoryTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -34,6 +34,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
namespace MySql.EntityFrameworkCore.Migrations.Tests
{
@@ -80,9 +81,8 @@ public void CanCreateDatabase()
var creator = context.GetService();
var cmdBuilder = context.GetService();
- Assert.False(creator.Exists());
- Assert.AreEqual("IF EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = 'MigrationId')\nBEGIN",
- cmdBuilder.Build(repository.GetBeginIfExistsScript("MigrationId")).CommandText.Replace("\r", string.Empty));
+ Assert.That(!creator.Exists());
+ Assert.That(cmdBuilder.Build(repository.GetBeginIfExistsScript("MigrationId")).CommandText.Replace("\r", string.Empty), Is.EqualTo("IF EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = 'MigrationId')\nBEGIN"));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLMigrationsTests.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLMigrationsTests.cs
index c4ef3aec4..c19d102ca 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLMigrationsTests.cs
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySQLMigrationsTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -31,7 +31,9 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.DependencyInjection;
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
+using MySql.EntityFrameworkCore.Migrations.Tests.TestData;
using NUnit.Framework;
+using System.Threading.Tasks;
namespace MySql.EntityFrameworkCore.Migrations.Tests
{
@@ -51,5 +53,35 @@ public void Can_generate_migration_from_initial_database_to_initial()
migrator.GenerateScript(fromMigration: Migration.InitialDatabase, toMigration: Migration.InitialDatabase);
}
}
+
+ //Bug #37513445 Cannot Perform Database Migration using MySql.EntityFrameworkCore 9.0.0
+ [Test]
+ public void TryPerformMigration()
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseMySQL(MySQLTestStore.RootConnectionString + "database=test;");
+
+ using (var mytestContext = new MyTestContext(optionsBuilder.Options))
+ {
+ mytestContext.Database.EnsureCreated();
+ mytestContext.Database.EnsureDeleted();
+ mytestContext.Database.Migrate();
+
+ Assert.That(mytestContext.Database.CanConnect(), Is.True);
+ mytestContext.Database.EnsureDeleted();
+ }
+ }
+
+ //Bug#37462099 MySql.EntityFrameworkCore 8.0.8 rename bug
+ [Test]
+ public async Task MigrationFailsWIthRenameColumn()
+ {
+ Bug37462099Context context = new Bug37462099Context();
+
+ context.Database.EnsureCreated();
+ context.Database.EnsureDeleted();
+ await context.Database.MigrateAsync();
+ context.Database.EnsureDeleted();
+ }
}
}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySql.EntityFrameworkCore.Migrations.Tests.csproj b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySql.EntityFrameworkCore.Migrations.Tests.csproj
index 820f237f9..dca0d5bed 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySql.EntityFrameworkCore.Migrations.Tests.csproj
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySql.EntityFrameworkCore.Migrations.Tests.csproj
@@ -2,7 +2,7 @@
MySql.EntityFrameworkCore.Migrations.Tests Class Library
- net6.0;net7.0;net8.0;
+ net9.0;net8.0;
MySql.EntityFrameworkCore.Migrations.Tests
MySql.EntityFrameworkCore.Migrations.Tests
true
@@ -13,10 +13,14 @@
$(NoWarn);CS1591,EF1001
+
+ $(TargetFrameworks);net10.0
+
+
-
-
-
+
+
+
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTest.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTest.cs
index 15d247903..53b36fcaa 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTest.cs
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTest.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -33,6 +33,7 @@
using MySql.EntityFrameworkCore.Basic.Tests.Utils;
using MySql.EntityFrameworkCore.Extensions;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
namespace MySql.EntityFrameworkCore.Migrations.Tests
{
@@ -71,7 +72,7 @@ public override void CreateTableOperation()
");" + EOL;
string fullResult = result.Replace(" NULL,", ",");
- Assert.True(result == Sql || fullResult == Sql);
+ Assert.That(result == Sql || fullResult == Sql);
}
[Test]
@@ -80,28 +81,28 @@ public override void AddColumnOperation_with_maxLength()
base.AddColumnOperation_with_maxLength();
string result = "ALTER TABLE `Person` ADD `Name` varchar(30);" + EOL;
string fullResult = "ALTER TABLE `Person` ADD `Name` varchar(30) NULL;" + EOL;
- Assert.True(result == Sql || fullResult == Sql);
+ Assert.That(result == Sql || fullResult == Sql);
}
[Test]
public override void AddColumnOperationWithComputedValueSql()
{
base.AddColumnOperationWithComputedValueSql();
- Assert.AreEqual("ALTER TABLE `People` ADD `DisplayName` varchar(50) AS (CONCAT_WS(' ', LastName , FirstName));" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("ALTER TABLE `People` ADD `DisplayName` varchar(50) AS (CONCAT_WS(' ', LastName , FirstName));" + EOL));
}
[Test]
public override void AddColumnOperationWithDefaultValueSql()
{
base.AddColumnOperationWithDefaultValueSql();
- Assert.AreEqual("ALTER TABLE `People` ADD `Timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("ALTER TABLE `People` ADD `Timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP;" + EOL));
}
[Test]
public override void AlterColumnOperation()
{
base.AlterColumnOperation();
- Assert.AreEqual("ALTER TABLE `Person` MODIFY `Age` int NOT NULL DEFAULT 7;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("ALTER TABLE `Person` MODIFY `Age` int NOT NULL DEFAULT 7;" + EOL));
}
@@ -109,21 +110,21 @@ public override void AlterColumnOperation()
public override void AlterColumnOperationWithoutType()
{
base.AlterColumnOperationWithoutType();
- Assert.AreEqual("ALTER TABLE `Person` MODIFY `Age` int NOT NULL;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("ALTER TABLE `Person` MODIFY `Age` int NOT NULL;" + EOL));
}
[Test]
public override void RenameTableOperationInSchema()
{
base.RenameTableOperationInSchema();
- Assert.AreEqual("ALTER TABLE t1 RENAME t2;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("ALTER TABLE t1 RENAME t2;" + EOL));
}
[Test]
public override void CreateUniqueIndexOperation()
{
base.CreateUniqueIndexOperation();
- Assert.AreEqual("CREATE UNIQUE INDEX `IXPersonName` ON `Person` (`FirstName`, `LastName`);" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("CREATE UNIQUE INDEX `IXPersonName` ON `Person` (`FirstName`, `LastName`);" + EOL));
}
[Test]
@@ -131,7 +132,7 @@ public override void CreateNonUniqueIndexOperation()
{
base.CreateNonUniqueIndexOperation();
- Assert.AreEqual("CREATE INDEX `IXPersonName` ON `Person` (`Name`);" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("CREATE INDEX `IXPersonName` ON `Person` (`Name`);" + EOL));
}
[Test]
@@ -139,28 +140,28 @@ public override void CreateNonUniqueIndexOperation()
public override void RenameIndexOperation()
{
base.RenameIndexOperation();
- Assert.AreEqual("DROP INDEX IXPersonName ON Person; CREATE INDEX IXNombre;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("DROP INDEX IXPersonName ON Person; CREATE INDEX IXNombre;" + EOL));
}
[Test]
public override void DropIndexOperation()
{
base.DropIndexOperation();
- Assert.AreEqual("DROP INDEX IXPersonName ON Person;" + EOL, Sql);
+ Assert.That(Sql, Is.EqualTo("DROP INDEX IXPersonName ON Person;" + EOL));
}
[Test]
public override void DropPrimaryKeyOperation()
{
base.DropPrimaryKeyOperation();
- Assert.AreEqual(string.Empty, Sql);
+ Assert.That(Sql, Is.EqualTo(string.Empty));
}
[Test]
public override void AddPrimaryKeyOperation()
{
base.AddPrimaryKeyOperation();
- Assert.AreEqual(string.Empty, Sql);
+ Assert.That(Sql, Is.EqualTo(string.Empty));
}
}
}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTestBase.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTestBase.cs
index b67616ac8..402723c3e 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTestBase.cs
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/MySqlMigrationsGeneratorTestBase.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -33,6 +33,7 @@
using MySql.EntityFrameworkCore.Metadata.Internal;
using MySql.EntityFrameworkCore.Migrations.Tests.Utilities;
using NUnit.Framework;
+using NUnit.Framework.Legacy;
using System;
using System.Linq;
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Context.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Context.cs
new file mode 100644
index 000000000..f01d4eb3a
--- /dev/null
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Context.cs
@@ -0,0 +1,74 @@
+// Copyright © 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.ComponentModel.DataAnnotations;
+using MySql.EntityFrameworkCore.Basic.Tests.Utils;
+
+namespace MySql.EntityFrameworkCore.Migrations.Tests.TestData
+{
+ public class Bug37462099Context : DbContext
+ {
+ public DbSet Entity { get; set; }
+
+ public Bug37462099Context() : base()
+ {
+ }
+
+ public Bug37462099Context(DbContextOptions options) : base(options)
+ {
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(builder =>
+ {
+ builder.ToTable("Bug37462099");
+
+ builder.HasKey(p => p.Id);
+
+ builder.Property(p => p.Name);
+
+ builder.Property(p => p.Created);
+ });
+ }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ => options.UseMySQL(MySQLTestStore.RootConnectionString + "database=test;");
+ }
+
+ public class Bug37462099
+ {
+ [Key]
+ public int Id { get; set; }
+ public string? Name { get; set; }
+ public DateTimeOffset Created { get; set; }
+
+ }
+}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099ContextModelSnapshot.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099ContextModelSnapshot.cs
new file mode 100644
index 000000000..41a49b529
--- /dev/null
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099ContextModelSnapshot.cs
@@ -0,0 +1,68 @@
+// Copyright © 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace MySql.EntityFrameworkCore.Migrations.Tests.TestData
+{
+ [DbContext(typeof(Bug37462099Context))]
+ partial class Bug37462099ContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("MySql.EntityFrameworkCore.Migrations.Tests.TestData.Bug37462099", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Created")
+ .HasColumnType("datetime");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Bug37462099", (string)null);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.Designer.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.Designer.cs
new file mode 100644
index 000000000..898193d40
--- /dev/null
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.Designer.cs
@@ -0,0 +1,71 @@
+// Copyright © 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace MySql.EntityFrameworkCore.Migrations.Tests.TestData
+{
+ [DbContext(typeof(Bug37462099Context))]
+ [Migration("Bug37462099Migrations")]
+ partial class Bug37462099Migrations
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("MySql.EntityFrameworkCore.Migrations.Tests.TestData.Bug37462099", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Created")
+ .HasColumnType("datetime");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Bug37462099", (string)null);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.cs
new file mode 100644
index 000000000..9e85e86ac
--- /dev/null
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/TestData/Bug37462099Migrations.cs
@@ -0,0 +1,78 @@
+// Copyright © 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using MySql.EntityFrameworkCore.Metadata;
+
+#nullable disable
+
+namespace MySql.EntityFrameworkCore.Migrations.Tests.TestData
+{
+ ///
+ public partial class Bug37462099Migrations : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySQL:Charset", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Bug37462099",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false).Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(type: "longtext", nullable: true),
+ Created = table.Column(type: "datetime", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Bug37462099", x => x.Id);
+ })
+ .Annotation("MySQL:Charset", "utf8mb4");
+
+ migrationBuilder.RenameColumn(
+ name: "Name",
+ table: "Bug37462099",
+ newName: "ChangedName").Annotation("Relational:ColumnType", "LONGTEXT;");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Bug37462099");
+
+ migrationBuilder.RenameColumn(
+ name: "ChangedName",
+ table: "Bug37462099",
+ newName: "Name").Annotation("Relational:ColumnType", "LONGTEXT;");
+ }
+ }
+}
diff --git a/EFCore/tests/MySql.EFCore.Migrations.Tests/Utilities/ContextUtils.cs b/EFCore/tests/MySql.EFCore.Migrations.Tests/Utilities/ContextUtils.cs
index 24afa9349..813de5cde 100644
--- a/EFCore/tests/MySql.EFCore.Migrations.Tests/Utilities/ContextUtils.cs
+++ b/EFCore/tests/MySql.EFCore.Migrations.Tests/Utilities/ContextUtils.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
+// Copyright © 2021, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/EFMySqlCommand.cs b/EntityFramework/src/EFMySqlCommand.cs
index 39cc3af41..9fcb1a1c9 100644
--- a/EntityFramework/src/EFMySqlCommand.cs
+++ b/EntityFramework/src/EFMySqlCommand.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2021, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/EFMySqlDataReader.cs b/EntityFramework/src/EFMySqlDataReader.cs
index 791fa4e8c..68d923bf4 100644
--- a/EntityFramework/src/EFMySqlDataReader.cs
+++ b/EntityFramework/src/EFMySqlDataReader.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Fragments/InputFragment.cs b/EntityFramework/src/Fragments/InputFragment.cs
index 464932eac..f55461249 100644
--- a/EntityFramework/src/Fragments/InputFragment.cs
+++ b/EntityFramework/src/Fragments/InputFragment.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Fragments/JoinFragment.cs b/EntityFramework/src/Fragments/JoinFragment.cs
index a3cdb7492..dde7a8608 100644
--- a/EntityFramework/src/Fragments/JoinFragment.cs
+++ b/EntityFramework/src/Fragments/JoinFragment.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Fragments/SqlFragment.cs b/EntityFramework/src/Fragments/SqlFragment.cs
index 82aea8756..1e16b734f 100644
--- a/EntityFramework/src/Fragments/SqlFragment.cs
+++ b/EntityFramework/src/Fragments/SqlFragment.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Fragments/TableFragment.cs b/EntityFramework/src/Fragments/TableFragment.cs
index cd536d9d0..a0371d500 100644
--- a/EntityFramework/src/Fragments/TableFragment.cs
+++ b/EntityFramework/src/Fragments/TableFragment.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2021, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -68,4 +68,4 @@ internal override void Accept(SqlFragmentVisitor visitor)
visitor.Visit(this);
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/src/Generators/DeleteGenerator.cs b/EntityFramework/src/Generators/DeleteGenerator.cs
index 0a4a500d8..d23018443 100644
--- a/EntityFramework/src/Generators/DeleteGenerator.cs
+++ b/EntityFramework/src/Generators/DeleteGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/FunctionGenerator.cs b/EntityFramework/src/Generators/FunctionGenerator.cs
index 968aefdb1..b5f9f6197 100644
--- a/EntityFramework/src/Generators/FunctionGenerator.cs
+++ b/EntityFramework/src/Generators/FunctionGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/FunctionProcessor.cs b/EntityFramework/src/Generators/FunctionProcessor.cs
index bc0f1640e..0db93eafa 100644
--- a/EntityFramework/src/Generators/FunctionProcessor.cs
+++ b/EntityFramework/src/Generators/FunctionProcessor.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/InsertGenerator.cs b/EntityFramework/src/Generators/InsertGenerator.cs
index 5968a2378..9dda3075a 100644
--- a/EntityFramework/src/Generators/InsertGenerator.cs
+++ b/EntityFramework/src/Generators/InsertGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/Scope.cs b/EntityFramework/src/Generators/Scope.cs
index a73f12780..cf7b7d873 100644
--- a/EntityFramework/src/Generators/Scope.cs
+++ b/EntityFramework/src/Generators/Scope.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/SelectGenerator.cs b/EntityFramework/src/Generators/SelectGenerator.cs
index 222c9fc0e..5ef0362af 100644
--- a/EntityFramework/src/Generators/SelectGenerator.cs
+++ b/EntityFramework/src/Generators/SelectGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/SqlGenerator.cs b/EntityFramework/src/Generators/SqlGenerator.cs
index 14091317c..a7cf234d3 100644
--- a/EntityFramework/src/Generators/SqlGenerator.cs
+++ b/EntityFramework/src/Generators/SqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Generators/UpdateGenerator.cs b/EntityFramework/src/Generators/UpdateGenerator.cs
index 7b309719b..ac8c1aee8 100644
--- a/EntityFramework/src/Generators/UpdateGenerator.cs
+++ b/EntityFramework/src/Generators/UpdateGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Metadata.cs b/EntityFramework/src/Metadata.cs
index 95cb3024d..414c4726f 100644
--- a/EntityFramework/src/Metadata.cs
+++ b/EntityFramework/src/Metadata.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, , Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySql.Data.EntityFramework.csproj b/EntityFramework/src/MySql.Data.EntityFramework.csproj
index 3ad54520c..8f33df2a4 100644
--- a/EntityFramework/src/MySql.Data.EntityFramework.csproj
+++ b/EntityFramework/src/MySql.Data.EntityFramework.csproj
@@ -2,27 +2,36 @@
MySql.Data.EntityFramework
- Copyright (c) 2016, 2023, Oracle and/or its affiliates.
+ Copyright © 2008, 2025, Oracle and/or its affiliates.
en-US
- 8.2.0
- Oracle
- net462;netstandard2.1;
+ 9.4.0
+ Oracle Corporation
+ net462;net48;netstandard2.1
$(NoWarn);CS1591
MySql.Data.EntityFramework
MySql.Data.EntityFramework
MySql;.NET Connector;MySql Connector/NET
- http://www.mysql.com/common/logos/logo-mysql-170x115.png
+ logo-mysql-170x115.png
+ README.md
https://dev.mysql.com/downloads/
- GPL-2.0-only
+ GPL-2.0-only WITH Universal-FOSS-exception-1.0
true
- false
- false
- false
- false
- false
- false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -63,7 +72,7 @@
-
+
diff --git a/EntityFramework/src/MySqlConnectionFactory.cs b/EntityFramework/src/MySqlConnectionFactory.cs
index 05385119c..6777c323f 100644
--- a/EntityFramework/src/MySqlConnectionFactory.cs
+++ b/EntityFramework/src/MySqlConnectionFactory.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -53,4 +53,4 @@ public DbConnection CreateConnection(string connectionString)
return new MySqlConnection(connectionString);
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/src/MySqlDependencyResolver.cs b/EntityFramework/src/MySqlDependencyResolver.cs
index 478791e44..189c23353 100644
--- a/EntityFramework/src/MySqlDependencyResolver.cs
+++ b/EntityFramework/src/MySqlDependencyResolver.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlEFConfiguration.cs b/EntityFramework/src/MySqlEFConfiguration.cs
index abc7e2327..36ce383f7 100644
--- a/EntityFramework/src/MySqlEFConfiguration.cs
+++ b/EntityFramework/src/MySqlEFConfiguration.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlExecutionStrategy.cs b/EntityFramework/src/MySqlExecutionStrategy.cs
index 04dc463f6..1fa6a8348 100644
--- a/EntityFramework/src/MySqlExecutionStrategy.cs
+++ b/EntityFramework/src/MySqlExecutionStrategy.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -244,4 +244,4 @@ public BackoffAlgorithmNdb()
{
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/src/MySqlHistoryContext.cs b/EntityFramework/src/MySqlHistoryContext.cs
index b209507fd..8154745b2 100644
--- a/EntityFramework/src/MySqlHistoryContext.cs
+++ b/EntityFramework/src/MySqlHistoryContext.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlLogger.cs b/EntityFramework/src/MySqlLogger.cs
index 553d1b144..9b7863bf3 100644
--- a/EntityFramework/src/MySqlLogger.cs
+++ b/EntityFramework/src/MySqlLogger.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlMigrationSqlGenerator.cs b/EntityFramework/src/MySqlMigrationSqlGenerator.cs
index 8ca716a3e..5fc83f782 100644
--- a/EntityFramework/src/MySqlMigrationSqlGenerator.cs
+++ b/EntityFramework/src/MySqlMigrationSqlGenerator.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2021, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlSpatialDataReader.cs b/EntityFramework/src/MySqlSpatialDataReader.cs
index 5ae81d43b..8425a70da 100644
--- a/EntityFramework/src/MySqlSpatialDataReader.cs
+++ b/EntityFramework/src/MySqlSpatialDataReader.cs
@@ -1,16 +1,16 @@
-// Copyright © 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/MySqlSpatialServices.cs b/EntityFramework/src/MySqlSpatialServices.cs
index f9bb26f48..bd7071d35 100644
--- a/EntityFramework/src/MySqlSpatialServices.cs
+++ b/EntityFramework/src/MySqlSpatialServices.cs
@@ -1,16 +1,16 @@
-// Copyright © 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Properties/AssemblyInfo.cs b/EntityFramework/src/Properties/AssemblyInfo.cs
index dc7661c9c..b99934a90 100644
--- a/EntityFramework/src/Properties/AssemblyInfo.cs
+++ b/EntityFramework/src/Properties/AssemblyInfo.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2023, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -30,19 +30,21 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System;
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("MySql.Data.EntityFramework for EF6")]
-[assembly: AssemblyDescription("Entity Framework 6.0 supported")]
-
+[assembly: AssemblyTitle("MySql.Data.EntityFramework")]
+[assembly: AssemblyDescription("MySql.Data.EntityFramework adds support for cross-platform application deployment with the Entity Framework 6.4 version.")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Oracle")]
-[assembly: AssemblyProduct("MySql.Data.EntityFramework")]
-[assembly: AssemblyCopyright("Copyright © 2008, 2023, Oracle and/or its affiliates.")]
-[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCompany("Oracle Corporation")]
+[assembly: AssemblyProduct("MySQL Connector/NET")]
+[assembly: AssemblyCopyright("Copyright © 2008, 2025, Oracle and/or its affiliates.")]
+[assembly: AssemblyTrademark("Oracle®, Java, MySQL, and NetSuite are registered trademarks of Oracle and/or its affiliates.")]
[assembly: AssemblyCulture("")]
+[assembly: SecurityRules(SecurityRuleSet.Level1)]
+[assembly: CLSCompliant(false)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
diff --git a/EntityFramework/src/Properties/Resources.Designer.cs b/EntityFramework/src/Properties/Resources.Designer.cs
index 8ecbdd21c..3dd3a9932 100644
--- a/EntityFramework/src/Properties/Resources.Designer.cs
+++ b/EntityFramework/src/Properties/Resources.Designer.cs
@@ -1,99 +1,99 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace MySql.Data.EntityFramework.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MySql.Data.EntityFramework.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to The connection parameter must reference an object of type MySql.Data.MySqlConnection.
- ///
- internal static string ConnectionMustBeOfTypeMySqlConnection {
- get {
- return ResourceManager.GetString("ConnectionMustBeOfTypeMySqlConnection", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'..
- ///
- internal static string NoStoreTypeForEdmType {
- get {
- return ResourceManager.GetString("NoStoreTypeForEdmType", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The underlying provider does not support the type '{0}'..
- ///
- internal static string TypeNotSupported {
- get {
- return ResourceManager.GetString("TypeNotSupported", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Result type of a function is expected to be a collection of RowType or PrimitiveType.
- ///
- internal static string WrongFunctionResultType {
- get {
- return ResourceManager.GetString("WrongFunctionResultType", resourceCulture);
- }
- }
- }
-}
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace MySql.Data.EntityFramework.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MySql.Data.EntityFramework.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The connection parameter must reference an object of type MySql.Data.MySqlConnection.
+ ///
+ internal static string ConnectionMustBeOfTypeMySqlConnection {
+ get {
+ return ResourceManager.GetString("ConnectionMustBeOfTypeMySqlConnection", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'..
+ ///
+ internal static string NoStoreTypeForEdmType {
+ get {
+ return ResourceManager.GetString("NoStoreTypeForEdmType", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The underlying provider does not support the type '{0}'..
+ ///
+ internal static string TypeNotSupported {
+ get {
+ return ResourceManager.GetString("TypeNotSupported", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Result type of a function is expected to be a collection of RowType or PrimitiveType.
+ ///
+ internal static string WrongFunctionResultType {
+ get {
+ return ResourceManager.GetString("WrongFunctionResultType", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/EntityFramework/src/Properties/VersionInfo.cs b/EntityFramework/src/Properties/VersionInfo.cs
new file mode 100644
index 000000000..e577111b1
--- /dev/null
+++ b/EntityFramework/src/Properties/VersionInfo.cs
@@ -0,0 +1,46 @@
+// Copyright © 2024, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Reflection;
+using System.Resources;
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("9.4.0")]
+[assembly: AssemblyInformationalVersion("9.4.0.0")]
+[assembly: AssemblyFileVersion("9.4.0.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
diff --git a/EntityFramework/src/ProviderManifest.cs b/EntityFramework/src/ProviderManifest.cs
index 24ca857ba..e2cf1a83a 100644
--- a/EntityFramework/src/ProviderManifest.cs
+++ b/EntityFramework/src/ProviderManifest.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/ProviderServices.cs b/EntityFramework/src/ProviderServices.cs
index a10f90a7a..e48803aad 100644
--- a/EntityFramework/src/ProviderServices.cs
+++ b/EntityFramework/src/ProviderServices.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2020, Oracle and/or its affiliates.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Statements/DeleteStatement.cs b/EntityFramework/src/Statements/DeleteStatement.cs
index 345578028..28dab1486 100644
--- a/EntityFramework/src/Statements/DeleteStatement.cs
+++ b/EntityFramework/src/Statements/DeleteStatement.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Statements/InsertStatement.cs b/EntityFramework/src/Statements/InsertStatement.cs
index 09cfa9370..0b22db824 100644
--- a/EntityFramework/src/Statements/InsertStatement.cs
+++ b/EntityFramework/src/Statements/InsertStatement.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/src/Statements/SelectStatement.cs b/EntityFramework/src/Statements/SelectStatement.cs
index c802edb45..cf355998e 100644
--- a/EntityFramework/src/Statements/SelectStatement.cs
+++ b/EntityFramework/src/Statements/SelectStatement.cs
@@ -1,16 +1,16 @@
-// Copyright (C) 2008, 2021, Oracle and/or its affiliates.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -232,7 +232,7 @@ List GetDefaultColumnsForFragment(InputFragment input)
if (generator.GetTopOp() == OpType.Join)
{
newColumn.ColumnAlias = cf.ColumnAlias;
- newColumn.PushInput(cf.ColumnName);
+ newColumn.PushInput(cf.ActualColumnName);
if (cf.TableName != null)
newColumn.PushInput(cf.TableName);
}
diff --git a/EntityFramework/src/Statements/UpdateStatement.cs b/EntityFramework/src/Statements/UpdateStatement.cs
index 3dc7db55d..110106dd4 100644
--- a/EntityFramework/src/Statements/UpdateStatement.cs
+++ b/EntityFramework/src/Statements/UpdateStatement.cs
@@ -1,16 +1,16 @@
-// Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/AggregateOperators.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/AggregateOperators.cs
index ac55d9e3b..2a19d098a 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/AggregateOperators.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/AggregateOperators.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/CanonicalFunctions.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/CanonicalFunctions.cs
index dc3cea487..1d9e66635 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/CanonicalFunctions.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/CanonicalFunctions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -64,13 +64,13 @@ public void Bitwise()
var context = ((IObjectContextAdapter)ctx).ObjectContext;
ObjectQuery q = context.CreateQuery("BitwiseAnd(255,15)");
foreach (int i in q)
- Assert.AreEqual(15, i);
+ Assert.That(i, Is.EqualTo(15));
q = context.CreateQuery("BitwiseOr(240,31)");
foreach (int i in q)
- Assert.AreEqual(255, i);
+ Assert.That(i, Is.EqualTo(255));
q = context.CreateQuery("BitwiseXor(255,15)");
foreach (int i in q)
- Assert.AreEqual(240, i);
+ Assert.That(i, Is.EqualTo(240));
}
}
@@ -85,9 +85,9 @@ public void CurrentDateTime()
ObjectQuery q = context.CreateQuery("CurrentDateTime()");
foreach (DateTime dt in q)
{
- Assert.AreEqual(current.Year, dt.Year);
- Assert.AreEqual(current.Month, dt.Month);
- Assert.AreEqual(current.Day, dt.Day);
+ Assert.That(dt.Year, Is.EqualTo(current.Year));
+ Assert.That(dt.Month, Is.EqualTo(current.Month));
+ Assert.That(dt.Day, Is.EqualTo(current.Day));
// we don't check time as that will be always be different
}
}
@@ -104,9 +104,9 @@ public void YearMonthDay()
FROM Companies AS c WHERE c.Id=1");
foreach (DbDataRecord record in q)
{
- Assert.AreEqual(1996, record[1]);
- Assert.AreEqual(11, record[2]);
- Assert.AreEqual(15, record[3]);
+ Assert.That(record[1], Is.EqualTo(1996));
+ Assert.That(record[2], Is.EqualTo(11));
+ Assert.That(record[3], Is.EqualTo(15));
}
}
}
@@ -122,9 +122,9 @@ public void HourMinuteSecond()
FROM Companies AS c WHERE c.Id=1");
foreach (DbDataRecord record in q)
{
- Assert.AreEqual(5, record[1]);
- Assert.AreEqual(18, record[2]);
- Assert.AreEqual(23, record[3]);
+ Assert.That(record[1], Is.EqualTo(5));
+ Assert.That(record[2], Is.EqualTo(18));
+ Assert.That(record[3], Is.EqualTo(23));
}
}
}
@@ -137,11 +137,11 @@ public void IndexOf()
var context = ((IObjectContextAdapter)ctx).ObjectContext;
ObjectQuery q = context.CreateQuery(@"IndexOf('needle', 'haystackneedle')");
foreach (int index in q)
- Assert.AreEqual(9, index);
+ Assert.That(index, Is.EqualTo(9));
q = context.CreateQuery(@"IndexOf('haystack', 'needle')");
foreach (int index in q)
- Assert.AreEqual(0, index);
+ Assert.That(index, Is.EqualTo(0));
}
}
@@ -154,17 +154,17 @@ public void LeftRight()
string entitySQL = "CONCAT(LEFT('foo',3),RIGHT('bar',3))";
ObjectQuery query = context.CreateQuery(entitySQL);
foreach (string s in query)
- Assert.AreEqual("foobar", s);
+ Assert.That(s, Is.EqualTo("foobar"));
entitySQL = "CONCAT(LEFT('foobar',3),RIGHT('barfoo',3))";
query = context.CreateQuery(entitySQL);
foreach (string s in query)
- Assert.AreEqual("foofoo", s);
+ Assert.That(s, Is.EqualTo("foofoo"));
entitySQL = "CONCAT(LEFT('foobar',8),RIGHT('barfoo',8))";
query = context.CreateQuery(entitySQL);
foreach (string s in query)
- Assert.AreEqual("foobarbarfoo", s);
+ Assert.That(s, Is.EqualTo("foobarbarfoo"));
}
}
@@ -177,7 +177,7 @@ public void Length()
string entitySQL = "Length('abc')";
ObjectQuery query = context.CreateQuery(entitySQL);
foreach (int len in query)
- Assert.AreEqual(3, len);
+ Assert.That(len, Is.EqualTo(3));
}
}
@@ -189,13 +189,13 @@ public void Trims()
var context = ((IObjectContextAdapter)ctx).ObjectContext;
ObjectQuery query = context.CreateQuery("LTrim(' text ')");
foreach (string s in query)
- Assert.AreEqual("text ", s);
+ Assert.That(s, Is.EqualTo("text "));
query = context.CreateQuery("RTrim(' text ')");
foreach (string s in query)
- Assert.AreEqual(" text", s);
+ Assert.That(s, Is.EqualTo(" text"));
query = context.CreateQuery("Trim(' text ')");
foreach (string s in query)
- Assert.AreEqual("text", s);
+ Assert.That(s, Is.EqualTo("text"));
}
}
@@ -213,11 +213,11 @@ public void Round()
FROM Products AS p WHERE p.Id=1");
foreach (DbDataRecord r in q)
{
- Assert.AreEqual(1, r[0]);
- Assert.AreEqual(8.865f, (float)r[1]);
- Assert.AreEqual(9, Convert.ToInt32(r[2]));
- Assert.AreEqual(8, Convert.ToInt32(r[3]));
- Assert.AreEqual(9, Convert.ToInt32(r[4]));
+ Assert.That(r[0], Is.EqualTo(1));
+ Assert.That((float)r[1], Is.EqualTo(8.865f));
+ Assert.That(Convert.ToInt32(r[2]), Is.EqualTo(9));
+ Assert.That(Convert.ToInt32(r[3]), Is.EqualTo(8));
+ Assert.That(Convert.ToInt32(r[4]), Is.EqualTo(9));
}
}
}
@@ -231,7 +231,7 @@ public void Substring()
ObjectQuery query = context.CreateQuery("SUBSTRING('foobarfoo',4,3)");
query = context.CreateQuery("SUBSTRING('foobarfoo',4,30)");
foreach (string s in query)
- Assert.AreEqual("barfoo", s);
+ Assert.That(s, Is.EqualTo("barfoo"));
}
}
@@ -246,9 +246,9 @@ public void ToUpperToLowerReverse()
Reverse(c.Name) FROM Companies AS c WHERE c.Id=1");
foreach (DbDataRecord r in q)
{
- Assert.AreEqual("HASBRO", r[0]);
- Assert.AreEqual("hasbro", r[1]);
- Assert.AreEqual("orbsaH", r[2]);
+ Assert.That(r[0], Is.EqualTo("HASBRO"));
+ Assert.That(r[1], Is.EqualTo("hasbro"));
+ Assert.That(r[2], Is.EqualTo("orbsaH"));
}
}
}
@@ -262,7 +262,7 @@ public void Replace()
ObjectQuery q = context.CreateQuery(
@"Replace('abcdefghi', 'def', 'zzz')");
foreach (string s in q)
- Assert.AreEqual("abczzzghi", s);
+ Assert.That(s, Is.EqualTo("abczzzghi"));
}
}
@@ -277,8 +277,8 @@ public void CanRoundToNonZeroDigits()
Round(p.Weight, 2) AS [Rounded Weight]
FROM Products AS p WHERE p.Id=1").First();
- Assert.AreEqual((float)8.865, (float)product[1]);
- Assert.AreEqual((double)8.86, (double)product[2]);
+ Assert.That((float)product[1], Is.EqualTo((float)8.865));
+ Assert.That((double)product[2], Is.EqualTo((double)8.86) );
}
}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DataTypeTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DataTypeTests.cs
index 8c0ca2e45..7e5471d39 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DataTypeTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DataTypeTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -57,7 +57,7 @@ public void TimeType()
ctx.SaveChanges();
Child d = ctx.Children.Where(x => x.ChildId == "ABC").Single();
- Assert.AreEqual(birth, d.BirthTime);
+ Assert.That(d.BirthTime, Is.EqualTo(birth));
}
}
@@ -111,7 +111,7 @@ public void TimestampColumn()
ctx.SaveChanges();
p = ctx.Products.First();
- Assert.AreEqual(now, p.CreatedDate);
+ Assert.That(p.CreatedDate, Is.EqualTo(now));
}
}
@@ -135,7 +135,7 @@ public void GuidType()
ctx.SaveChanges();
Child d = ctx.Children.Where(x => x.ChildId == "GUID").Single();
- Assert.AreEqual(g, d.Label);
+ Assert.That(d.Label, Is.EqualTo(g));
}
}
@@ -156,7 +156,7 @@ public void CanSetDbTypeDecimalFromNewDecimalParameter()
IsNullable = true
};
- Assert.AreEqual(DbType.Decimal, newDecimalParameter.DbType);
+ Assert.That(newDecimalParameter.DbType, Is.EqualTo(DbType.Decimal));
}
}
}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DatesTypesTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DatesTypesTests.cs
index c4fa0e221..801858c3c 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DatesTypesTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DatesTypesTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2011, 2023 Oracle and/or its affiliates.
+// Copyright © 2011, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -74,10 +74,7 @@ public class DatesTypesTests : DefaultFixture
[Test]
public void CanCreateDBScriptWithDateTimePrecision()
{
- if (!Environment.OSVersion.Platform.ToString().StartsWith("Win"))
- Assert.Ignore("Fix for Ubuntu. schema.Rows[3] -> System.IndexOutOfRangeException: There is no row at position 3.");
- if (Version < new Version(5, 6, 5))
- Assert.Ignore("MySQL Server version no compatible");
+ Assume.That(Version >= new Version(5, 6, 5));
using (var ctx = new TestContext(ConnectionString))
{
@@ -89,12 +86,12 @@ public void CanCreateDBScriptWithDateTimePrecision()
DataTable schema = Connection.GetSchema("COLUMNS", new string[] { null, Connection.Database, "widgets" });
DataRow row = schema.Rows[3];
- Assert.AreEqual("datetime", (string)row["DATA_TYPE"]);
- Assert.AreEqual("NO", (string)row["IS_NULLABLE"]);
+ Assert.That((string)row["DATA_TYPE"], Is.EqualTo("datetime"));
+ Assert.That((string)row["IS_NULLABLE"], Is.EqualTo("NO"));
if (Version < new Version(8, 0))
- Assert.AreEqual((uint)6, (UInt64)row["DATETIME_PRECISION"]);
+ Assert.That((UInt64)row["DATETIME_PRECISION"], Is.EqualTo((uint)6));
else
- Assert.AreEqual((uint)6, (UInt32)row["DATETIME_PRECISION"]);
+ Assert.That((UInt32)row["DATETIME_PRECISION"], Is.EqualTo((uint)6));
}
}
}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultContext.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultContext.cs
index 9632e679f..4c2b5ca82 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultContext.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultContext.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -149,4 +149,4 @@ public class LongDataTest
[StringLength(15)]
public string Data { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultFixture.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultFixture.cs
index 28c6b3f9c..8efdebde4 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultFixture.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DefaultFixture.cs
@@ -1,179 +1,179 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System.Data.Entity.Core.Objects;
-using System.Text.RegularExpressions;
-using System.Data.Entity.Infrastructure;
-using NUnit.Framework;
-using System;
-using MySql.Data.MySqlClient;
-
-namespace MySql.Data.EntityFramework.Tests
-{
- public class DefaultFixture
- {
- public string host { get; set; }
- public string user { get; set; }
- public string password { get; set; }
- public uint Port { get; set; }
- public string database { get; set; }
- public Version version { get; set; }
- public MySqlConnection Connection { get; set; }
- public string ConnectionString { get; set; }
- public bool NeedSetup { get; set; }
-
- public DefaultFixture()
- {
- NeedSetup = true;
- }
-
- [OneTimeSetUp]
- public void OneTimeSetup()
- {
- if (NeedSetup)
- {
- NeedSetup = false;
-
- database = "db-" + this.GetType().Name.ToLower();
- if (database.Length > 32)
- database = database.Substring(0, 32);
-
- MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();
- sb.Server = "localhost";
- string port = Environment.GetEnvironmentVariable("MYSQL_PORT");
- sb.Port = Port = string.IsNullOrEmpty(port) ? 3306 : uint.Parse(port);
- sb.UserID = "root";
- sb.Pooling = false;
- sb.AllowUserVariables = true;
- sb.Database = database;
- ConnectionString = sb.ToString();
-
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- if (ctx.Database.Exists())
- ctx.Database.Delete();
- var context = ((IObjectContextAdapter)ctx).ObjectContext;
- context.CreateDatabase();
- }
-
- Connection = new MySqlConnection(ConnectionString);
- Connection.Open();
- LoadData();
- }
- }
-
- [OneTimeTearDown]
- public void OneTimeTearDown()
- {
- MySqlConnection.ClearAllPools();
- ExecSQL($"DROP DATABASE IF EXISTS `{Connection.Database}`");
- Connection.Close();
- }
-
- [SetUp]
- public virtual void SetUp()
- {
- if (NeedSetup)
- {
- NeedSetup = false;
-
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- if (ctx.Database.Exists())
- ctx.Database.Delete();
- var context = ((IObjectContextAdapter)ctx).ObjectContext;
- context.CreateDatabase();
- }
-
- LoadData();
- }
- }
-
- [TearDown]
- public virtual void TearDown() { }
-
- public virtual void LoadData() { }
-
- public Version Version
- {
- get
- {
- if (version == null)
- {
- string versionString = Connection.ServerVersion;
- int i = 0;
- while (i < versionString.Length &&
- (Char.IsDigit(versionString[i]) || versionString[i] == '.'))
- i++;
-
- version = new Version(versionString.Substring(0, i));
- }
- return version;
- }
- }
-
- public void ExecSQL(string sql)
- {
- MySqlCommand cmd = new MySqlCommand(sql, Connection);
- cmd.ExecuteNonQuery();
- }
-
- public static void CheckSql(string actual, string expected)
- {
- var exp = Regex.Replace(expected, @"\s", string.Empty);
- var act = Regex.Replace(actual, @"\s", string.Empty);
- Assert.AreEqual(act, exp);
- }
-
- public static void CheckSqlContains(string actual, string expected)
- {
- var exp = Regex.Replace(expected, @"\s", string.Empty);
- var act = Regex.Replace(actual, @"\s", string.Empty);
- Assert.True(act.Contains(exp));
- }
-
- public DefaultContext GetDefaultContext()
- {
- return new DefaultContext(ConnectionString);
- }
-
- public void TestESql(string eSql, string expected, params ObjectParameter[] parms)
- {
- using (DefaultContext ctx = GetDefaultContext())
- {
- var context = ((IObjectContextAdapter)ctx).ObjectContext;
- ObjectQuery q = context.CreateQuery(eSql);
- foreach (var p in parms)
- q.Parameters.Add(p);
-
- string sql = q.ToTraceString();
- CheckSql(sql, expected);
- }
- }
- }
-}
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Data.Entity.Core.Objects;
+using System.Text.RegularExpressions;
+using System.Data.Entity.Infrastructure;
+using NUnit.Framework;
+using System;
+using MySql.Data.MySqlClient;
+
+namespace MySql.Data.EntityFramework.Tests
+{
+ public class DefaultFixture
+ {
+ public string host { get; set; }
+ public string user { get; set; }
+ public string password { get; set; }
+ public uint Port { get; set; }
+ public string database { get; set; }
+ public Version version { get; set; }
+ public MySqlConnection Connection { get; set; }
+ public string ConnectionString { get; set; }
+ public bool NeedSetup { get; set; }
+
+ public DefaultFixture()
+ {
+ NeedSetup = true;
+ }
+
+ [OneTimeSetUp]
+ public void OneTimeSetup()
+ {
+ if (NeedSetup)
+ {
+ NeedSetup = false;
+
+ database = "db-" + this.GetType().Name.ToLower();
+ if (database.Length > 32)
+ database = database.Substring(0, 32);
+
+ MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();
+ sb.Server = "localhost";
+ string port = Environment.GetEnvironmentVariable("MYSQL_PORT");
+ sb.Port = Port = string.IsNullOrEmpty(port) ? 3306 : uint.Parse(port);
+ sb.UserID = "root";
+ sb.Pooling = false;
+ sb.AllowUserVariables = true;
+ sb.Database = database;
+ ConnectionString = sb.ToString();
+
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ if (ctx.Database.Exists())
+ ctx.Database.Delete();
+ var context = ((IObjectContextAdapter)ctx).ObjectContext;
+ context.CreateDatabase();
+ }
+
+ Connection = new MySqlConnection(ConnectionString);
+ Connection.Open();
+ LoadData();
+ }
+ }
+
+ [OneTimeTearDown]
+ public void OneTimeTearDown()
+ {
+ MySqlConnection.ClearAllPools();
+ ExecSQL($"DROP DATABASE IF EXISTS `{Connection.Database}`");
+ Connection.Close();
+ }
+
+ [SetUp]
+ public virtual void SetUp()
+ {
+ if (NeedSetup)
+ {
+ NeedSetup = false;
+
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ if (ctx.Database.Exists())
+ ctx.Database.Delete();
+ var context = ((IObjectContextAdapter)ctx).ObjectContext;
+ context.CreateDatabase();
+ }
+
+ LoadData();
+ }
+ }
+
+ [TearDown]
+ public virtual void TearDown() { }
+
+ public virtual void LoadData() { }
+
+ public Version Version
+ {
+ get
+ {
+ if (version == null)
+ {
+ string versionString = Connection.ServerVersion;
+ int i = 0;
+ while (i < versionString.Length &&
+ (Char.IsDigit(versionString[i]) || versionString[i] == '.'))
+ i++;
+
+ version = new Version(versionString.Substring(0, i));
+ }
+ return version;
+ }
+ }
+
+ public void ExecSQL(string sql)
+ {
+ MySqlCommand cmd = new MySqlCommand(sql, Connection);
+ cmd.ExecuteNonQuery();
+ }
+
+ public static void CheckSql(string actual, string expected)
+ {
+ var exp = Regex.Replace(expected, @"\s", string.Empty);
+ var act = Regex.Replace(actual, @"\s", string.Empty);
+ Assert.That(exp, Is.EqualTo(act));
+ }
+
+ public static void CheckSqlContains(string actual, string expected)
+ {
+ var exp = Regex.Replace(expected, @"\s", string.Empty);
+ var act = Regex.Replace(actual, @"\s", string.Empty);
+ Assert.That(act.Contains(exp));
+ }
+
+ public DefaultContext GetDefaultContext()
+ {
+ return new DefaultContext(ConnectionString);
+ }
+
+ public void TestESql(string eSql, string expected, params ObjectParameter[] parms)
+ {
+ using (DefaultContext ctx = GetDefaultContext())
+ {
+ var context = ((IObjectContextAdapter)ctx).ObjectContext;
+ ObjectQuery q = context.CreateQuery(eSql);
+ foreach (var p in parms)
+ q.Parameters.Add(p);
+
+ string sql = q.ToTraceString();
+ CheckSql(sql, expected);
+ }
+ }
+ }
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DeleteTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DeleteTests.cs
index 27aa0034c..8429f1f6f 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DeleteTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/DeleteTests.cs
@@ -1,136 +1,136 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System.Linq;
-using NUnit.Framework;
-using System.Data;
-using System.Data.Entity;
-using System.Data.Entity.Infrastructure;
-
-namespace MySql.Data.EntityFramework.Tests
-{
-
- public class DeleteTests : DefaultFixture
- {
- public override void LoadData()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- ctx.Products.Add(new Product() { Name = "Garbage Truck", MinAge = 8 });
- ctx.Products.Add(new Product() { Name = "Fire Truck", MinAge = 12 });
- ctx.Products.Add(new Product() { Name = "Hula Hoop", MinAge = 18 });
- ctx.SaveChanges();
- }
- }
-
- [Test]
- public void SimpleDeleteAllRows()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- Assert.True(ctx.Products.Count() > 0);
-
- foreach (Product p in ctx.Products)
- ctx.Products.Remove(p);
- ctx.SaveChanges();
-
- Assert.AreEqual(0, ctx.Products.Count());
- }
- // set the flag that will cause the setup to happen again
- // since we just blew away a table
- NeedSetup = true;
- }
-
- [Test]
- public void SimpleDeleteRowByParameter()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- int total = ctx.Products.Count();
- int cntLeft = ctx.Products.Where(b => b.MinAge >= 18).Count();
- // make sure the test is valid
- Assert.True(total > cntLeft);
-
- foreach (Product p in ctx.Products.Where(b => b.MinAge < 18).ToList())
- ctx.Products.Remove(p);
- ctx.SaveChanges();
- Assert.AreEqual(cntLeft, ctx.Products.Count());
- }
- // set the flag that will cause the setup to happen again
- // since we just blew away a table
- NeedSetup = true;
- }
-
-
- public class Widget
- {
- public int Id { get; set; }
- public WidgetDetail Detail { get; set; }
- }
-
- public class WidgetDetail
- {
- public int Id { get; set; }
- public Widget Widget { get; set; }
- }
-
- public class WidgetContext : DbContext
- {
- public WidgetContext(string connStr) : base(connStr)
- {
- Database.SetInitializer(null);
- }
-
- protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity()
- .HasRequired(b => b.Widget)
- .WithOptional(a => a.Detail)
- .WillCascadeOnDelete(true);
- }
- }
-
- ///
- /// Fix for bug Cascading delete using CreateDatabase in Entity Framework
- /// (http://bugs.mysql.com/bug.php?id=64779) using ModelFirst.
- ///
- [Test]
- public void XOnDeleteCascade()
- {
- using (WidgetContext ctx = new WidgetContext(ConnectionString))
- {
- var context = ((IObjectContextAdapter)ctx).ObjectContext;
- var sql = context.CreateDatabaseScript();
- CheckSqlContains(sql,
- @"ALTER TABLE `WidgetDetails` ADD CONSTRAINT WidgetDetail_Widget
- FOREIGN KEY (Id) REFERENCES `Widgets` (Id) ON DELETE Cascade ON UPDATE NO ACTION;");
- }
- }
- }
-}
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Linq;
+using NUnit.Framework;
+using System.Data;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+
+namespace MySql.Data.EntityFramework.Tests
+{
+
+ public class DeleteTests : DefaultFixture
+ {
+ public override void LoadData()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ ctx.Products.Add(new Product() { Name = "Garbage Truck", MinAge = 8 });
+ ctx.Products.Add(new Product() { Name = "Fire Truck", MinAge = 12 });
+ ctx.Products.Add(new Product() { Name = "Hula Hoop", MinAge = 18 });
+ ctx.SaveChanges();
+ }
+ }
+
+ [Test]
+ public void SimpleDeleteAllRows()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ Assert.That(ctx.Products.Count() > 0);
+
+ foreach (Product p in ctx.Products)
+ ctx.Products.Remove(p);
+ ctx.SaveChanges();
+
+ Assert.That(ctx.Products.Count(), Is.EqualTo(0));
+ }
+ // set the flag that will cause the setup to happen again
+ // since we just blew away a table
+ NeedSetup = true;
+ }
+
+ [Test]
+ public void SimpleDeleteRowByParameter()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ int total = ctx.Products.Count();
+ int cntLeft = ctx.Products.Where(b => b.MinAge >= 18).Count();
+ // make sure the test is valid
+ Assert.That(total > cntLeft);
+
+ foreach (Product p in ctx.Products.Where(b => b.MinAge < 18).ToList())
+ ctx.Products.Remove(p);
+ ctx.SaveChanges();
+ Assert.That(ctx.Products.Count(), Is.EqualTo(cntLeft));
+ }
+ // set the flag that will cause the setup to happen again
+ // since we just blew away a table
+ NeedSetup = true;
+ }
+
+
+ public class Widget
+ {
+ public int Id { get; set; }
+ public WidgetDetail Detail { get; set; }
+ }
+
+ public class WidgetDetail
+ {
+ public int Id { get; set; }
+ public Widget Widget { get; set; }
+ }
+
+ public class WidgetContext : DbContext
+ {
+ public WidgetContext(string connStr) : base(connStr)
+ {
+ Database.SetInitializer(null);
+ }
+
+ protected override void OnModelCreating(DbModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+ modelBuilder.Entity()
+ .HasRequired(b => b.Widget)
+ .WithOptional(a => a.Detail)
+ .WillCascadeOnDelete(true);
+ }
+ }
+
+ ///
+ /// Fix for bug Cascading delete using CreateDatabase in Entity Framework
+ /// (http://bugs.mysql.com/bug.php?id=64779) using ModelFirst.
+ ///
+ [Test]
+ public void XOnDeleteCascade()
+ {
+ using (WidgetContext ctx = new WidgetContext(ConnectionString))
+ {
+ var context = ((IObjectContextAdapter)ctx).ObjectContext;
+ var sql = context.CreateDatabaseScript();
+ CheckSqlContains(sql,
+ @"ALTER TABLE `WidgetDetails` ADD CONSTRAINT WidgetDetail_Widget
+ FOREIGN KEY (Id) REFERENCES `Widgets` (Id) ON DELETE Cascade ON UPDATE NO ACTION;");
+ }
+ }
+ }
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ExpressionTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ExpressionTests.cs
index 3e2fdc28b..44667e099 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ExpressionTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ExpressionTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2015, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -54,7 +54,7 @@ public void CheckStartsWithWhenUsingVariable()
{
string str = "Garbage";
var records = ctx.Products.Where(p => p.Name.StartsWith(str)).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -67,7 +67,7 @@ public void CheckStartsWithWhenUsingValue()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
var records = ctx.Products.Where(p => p.Name.StartsWith("Garbage")).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -81,7 +81,7 @@ public void CheckEndsWithWhenUsingVariable()
{
string str = "Hoop";
var records = ctx.Products.Where(p => p.Name.EndsWith(str)).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -94,7 +94,7 @@ public void CheckEndsWithWhenUsingValue()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
var records = ctx.Products.Where(p => p.Name.EndsWith("Hoop")).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -109,7 +109,7 @@ public void CheckContainsWhenUsingVariable()
{
string str = "bage";
var records = ctx.Products.Where(p => p.Name.Contains(str)).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -123,7 +123,7 @@ public void CheckContainsWhenUsingHardCodedValue()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
var records = ctx.Products.Where(p => p.Name.Contains("bage")).ToArray();
- Assert.AreEqual(1, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(1));
}
}
@@ -136,7 +136,7 @@ public void CheckContainsWhenUsingHardCodedValueWithPercentageSymbol()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
var records = ctx.Products.Where(p => p.Name.Contains("%")).ToArray();
- Assert.AreEqual(0, records.Count());
+ Assert.That(records.Count(), Is.EqualTo(0));
}
}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/GenericListener.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/GenericListener.cs
index 9223458bb..dec000e96 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/GenericListener.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/GenericListener.cs
@@ -1,87 +1,87 @@
-// Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System.Text;
-using System.Diagnostics;
-using System.Collections.Specialized;
-
-namespace MySql.Data.EntityFramework.Tests
-{
- public class GenericListener : TraceListener
- {
-
- StringCollection strings;
- StringBuilder partial;
-
- public GenericListener()
- {
- strings = new StringCollection();
- partial = new StringBuilder();
- }
-
- public StringCollection Strings
- {
- get { return strings; }
- }
-
- public int Find(string sToFind)
- {
- int count = 0;
- foreach (string s in strings)
- if (s.IndexOf(sToFind) != -1)
- count++;
- return count;
- }
-
- public void Clear()
- {
- partial.Remove(0, partial.Length);
- strings.Clear();
- }
-
- public override void Write(string message)
- {
- partial.Append(message);
- }
-
- public override void WriteLine(string message)
- {
- Write(message);
- strings.Add(partial.ToString());
- partial.Remove(0, partial.Length);
- }
-
- public int CountLinesContaining(string text)
- {
- int count = 0;
- foreach (string s in strings)
- if (s.Contains(text)) count++;
- return count;
- }
- }
-}
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Text;
+using System.Diagnostics;
+using System.Collections.Specialized;
+
+namespace MySql.Data.EntityFramework.Tests
+{
+ public class GenericListener : TraceListener
+ {
+
+ StringCollection strings;
+ StringBuilder partial;
+
+ public GenericListener()
+ {
+ strings = new StringCollection();
+ partial = new StringBuilder();
+ }
+
+ public StringCollection Strings
+ {
+ get { return strings; }
+ }
+
+ public int Find(string sToFind)
+ {
+ int count = 0;
+ foreach (string s in strings)
+ if (s.IndexOf(sToFind) != -1)
+ count++;
+ return count;
+ }
+
+ public void Clear()
+ {
+ partial.Remove(0, partial.Length);
+ strings.Clear();
+ }
+
+ public override void Write(string message)
+ {
+ partial.Append(message);
+ }
+
+ public override void WriteLine(string message)
+ {
+ Write(message);
+ strings.Add(partial.ToString());
+ partial.Remove(0, partial.Length);
+ }
+
+ public int CountLinesContaining(string text)
+ {
+ int count = 0;
+ foreach (string s in strings)
+ if (s.Contains(text)) count++;
+ return count;
+ }
+ }
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/InsertTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/InsertTests.cs
index 8a447a7ed..2f1174097 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/InsertTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/InsertTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -58,11 +58,11 @@ public void InsertSingleRow()
ctx.Companies.Add(c);
int result = ctx.SaveChanges();
- Assert.AreEqual(beforeCnt + 1, ctx.Companies.Count());
+ Assert.That(ctx.Companies.Count(), Is.EqualTo(beforeCnt + 1));
Company d = ctx.Companies.Find(c.Id);
d.Id = c.Id;
- Assert.AreEqual(c, d);
+ Assert.That(d, Is.EqualTo(c));
}
}
@@ -93,12 +93,12 @@ public async Task ExecuteNonQueryAndScalarAsyncAwait()
proc.CommandType = CommandType.StoredProcedure;
int result = await proc.ExecuteNonQueryAsync();
- Assert.AreNotEqual(-1, result);
+ Assert.That(result, Is.Not.EqualTo(-1));
EFMySqlCommand cmd = new EFMySqlCommand() { CommandText = "SELECT COUNT(*) FROM NonQueryAndScalarAsyncAwaitTest;", Connection = Connection };
cmd.CommandType = CommandType.Text;
object cnt = await cmd.ExecuteScalarAsync();
- Assert.AreEqual(100, Convert.ToInt32(cnt));
+ Assert.That(Convert.ToInt32(cnt), Is.EqualTo(100));
}
[Test]
@@ -147,15 +147,15 @@ public void SqlModeReplacedByANSI()
LongDataTest longData = new LongDataTest();
longData.Data = "This does fit.";
ctx.LongDataTests.Add(longData);
- Assert.IsTrue(ctx.SaveChanges() == 1);
+ Assert.That(ctx.SaveChanges() == 1);
// Try to insert a value that is larger than the max lenght of the column
longData.Data = "This does not fit in the column!!!";
ctx.LongDataTests.Add(longData);
var ex = Assert.Throws(() => ctx.SaveChanges());
Assert.That(ex.InnerException.InnerException is MySqlException);
- StringAssert.AreEqualIgnoringCase("Data too long for column 'Data' at row 1", ex.InnerException.InnerException.Message);
+ Assert.That(ex.InnerException.InnerException.Message, Is.EqualTo("Data too long for column 'Data' at row 1").IgnoreCase);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/JoinTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/JoinTests.cs
index f31d10cd1..bad80f7c0 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/JoinTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/JoinTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -292,4 +292,4 @@ where b.Pages > 300
// }
// }
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/MySql.EntityFramework.Basic.Tests.csproj b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/MySql.EntityFramework.Basic.Tests.csproj
index fa40e0500..74db78daf 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/MySql.EntityFramework.Basic.Tests.csproj
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/MySql.EntityFramework.Basic.Tests.csproj
@@ -2,17 +2,17 @@
MySql.Data.EntityFramework.CodeFirTests
- Copyright (c) 2016, 2023, Oracle and/or its affiliates.
+ Copyright © 2016, 2025, Oracle and/or its affiliates.
en-US
- 8.2.0
+ 9.4.0
Oracle
- net7.0
+ net462;net48;net9.0
MySql.EntityFramework.Basic.Tests
MySql.EntityFramework.Basic.Tests
MySql;.NET Connector;MySql Connector/NET
http://www.mysql.com/common/logos/logo-mysql-170x115.png
http://dev.mysql.com/downloads/
- GPL-2.0-only
+ GPL-2.0-only WITH Universal-FOSS-exception-1.0
true
false
false
@@ -25,6 +25,7 @@
..\..\..\ConnectorNetPublicKey.snk
MySql.EntityFramework.Basic.Tests
CA2100
+ latest
@@ -33,21 +34,6 @@
-
-
-
-
-
-
-
- TRACE;DEBUG;NET452;
-
-
-
- TRACE;RELEASE;NET452;
-
-
-
@@ -58,8 +44,20 @@
+
+
+
+
+
+ TRACE;DEBUG;NET462;
+
+
+
+ TRACE;RELEASE;NET462;
+
+
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/OrderingAndGrouping.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/OrderingAndGrouping.cs
index 29f4f791e..c95c995df 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/OrderingAndGrouping.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/OrderingAndGrouping.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -106,4 +106,4 @@ public void OrdersTableDoesNotProvokeSyntaxError()
//}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Paging.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Paging.cs
index 70d98a558..aab415d67 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Paging.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Paging.cs
@@ -1,104 +1,104 @@
-// Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System.Data;
-using System.Linq;
-using NUnit.Framework;
-
-namespace MySql.Data.EntityFramework.Tests
-{
- public class Paging : DefaultFixture
- {
- public override void SetUp()
- {
- LoadData();
- }
-
- void LoadData()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- ctx.Products.Add(new Product() { Name = "Garbage Truck", MinAge = 8 });
- ctx.Products.Add(new Product() { Name = "Fire Truck", MinAge = 12 });
- ctx.Products.Add(new Product() { Name = "Hula Hoop", MinAge = 18 });
- ctx.SaveChanges();
- }
- }
-
- [Test]
- public void Take()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- var q = ctx.Books.Take(2);
- var sql = q.ToString();
- CheckSql(sql,
- @"SELECT `Id`, `Name`, `PubDate`, `Pages`, `Author_Id` FROM `Books` LIMIT 2");
- }
- }
-
- [Test]
- public void Skip()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- var q = ctx.Books.OrderBy(b=>b.Pages).Skip(3);
- var sql = q.ToString();
- CheckSql(sql,
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`, `Extent1`.`Author_Id`
- FROM `Books` AS `Extent1` ORDER BY `Extent1`.`Pages` ASC LIMIT 3,18446744073709551615");
- }
- }
-
- [Test]
- public void SkipAndTakeSimple()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- var q = ctx.Books.OrderBy(b => b.Pages).Skip(3).Take(4);
- var sql = q.ToString();
- CheckSql(sql,
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`, `Extent1`.`Author_Id`
- FROM `Books` AS `Extent1` ORDER BY `Extent1`.`Pages` ASC LIMIT 3,4");
- }
- }
-
- //
- // Tests fix for bug #64749 - Entity Framework - Take().Count() fails with EntityCommandCompilationException.
- //
- [Test]
- public void TakeWithCount()
- {
- using (DefaultContext ctx = new DefaultContext(ConnectionString))
- {
- int cnt = ctx.Products.Take(2).Count();
- Assert.AreEqual(2, cnt);
- }
- }
- }
-}
\ No newline at end of file
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Data;
+using System.Linq;
+using NUnit.Framework;
+
+namespace MySql.Data.EntityFramework.Tests
+{
+ public class Paging : DefaultFixture
+ {
+ public override void SetUp()
+ {
+ LoadData();
+ }
+
+ void LoadData()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ ctx.Products.Add(new Product() { Name = "Garbage Truck", MinAge = 8 });
+ ctx.Products.Add(new Product() { Name = "Fire Truck", MinAge = 12 });
+ ctx.Products.Add(new Product() { Name = "Hula Hoop", MinAge = 18 });
+ ctx.SaveChanges();
+ }
+ }
+
+ [Test]
+ public void Take()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ var q = ctx.Books.Take(2);
+ var sql = q.ToString();
+ CheckSql(sql,
+ @"SELECT `Id`, `Name`, `PubDate`, `Pages`, `Author_Id` FROM `Books` LIMIT 2");
+ }
+ }
+
+ [Test]
+ public void Skip()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ var q = ctx.Books.OrderBy(b=>b.Pages).Skip(3);
+ var sql = q.ToString();
+ CheckSql(sql,
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`, `Extent1`.`Author_Id`
+ FROM `Books` AS `Extent1` ORDER BY `Extent1`.`Pages` ASC LIMIT 3,18446744073709551615");
+ }
+ }
+
+ [Test]
+ public void SkipAndTakeSimple()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ var q = ctx.Books.OrderBy(b => b.Pages).Skip(3).Take(4);
+ var sql = q.ToString();
+ CheckSql(sql,
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`, `Extent1`.`Author_Id`
+ FROM `Books` AS `Extent1` ORDER BY `Extent1`.`Pages` ASC LIMIT 3,4");
+ }
+ }
+
+ //
+ // Tests fix for bug #64749 - Entity Framework - Take().Count() fails with EntityCommandCompilationException.
+ //
+ [Test]
+ public void TakeWithCount()
+ {
+ using (DefaultContext ctx = new DefaultContext(ConnectionString))
+ {
+ int cnt = ctx.Products.Take(2).Count();
+ Assert.That(cnt, Is.EqualTo(2));
+ }
+ }
+ }
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProceduresAndFunctions.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProceduresAndFunctions.cs
index 1c8006bb1..6a23d1b88 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProceduresAndFunctions.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProceduresAndFunctions.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -53,7 +53,7 @@ public void CallStoredProcedure()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
long count = ctx.Database.SqlQuery("call CallStoredProcedure").First();
- Assert.AreEqual(5, count);
+ Assert.That(count, Is.EqualTo(5));
}
}
@@ -69,7 +69,7 @@ public void UserDefinedFunction()
using (DefaultContext ctx = new DefaultContext(ConnectionString))
{
int val = ctx.Database.SqlQuery(@"SELECT spFunc()").Single();
- Assert.AreEqual(3, val);
+ Assert.That(val, Is.EqualTo(3));
}
}
@@ -94,4 +94,4 @@ public void CommandTimeout()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Properties/AssemblyInfo.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Properties/AssemblyInfo.cs
index 270be36bb..2bd86ed8d 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Properties/AssemblyInfo.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Properties/AssemblyInfo.cs
@@ -1,55 +1,55 @@
-// Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System.Reflection;
-using System.Runtime.InteropServices;
-using NUnit.Framework;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("MySql.Data.EntityFramework.Tests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Oracle")]
-[assembly: AssemblyProduct("MySql.Data.EntityFramework.Tests")]
-[assembly: AssemblyCopyright("Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("a4c0a8f2-5e48-4227-a712-bf8ae7446101")]
-
-//[assembly: InternalsVisibleTo("MySql.Data.EntityFramework.CodeFirTests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1")]
-
-[assembly: NonParallelizable]
\ No newline at end of file
+// Copyright © 2008, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+using NUnit.Framework;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MySql.Data.EntityFramework.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Oracle")]
+[assembly: AssemblyProduct("MySql.Data.EntityFramework.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2008, 2025, Oracle and/or its affiliates.")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a4c0a8f2-5e48-4227-a712-bf8ae7446101")]
+
+//[assembly: InternalsVisibleTo("MySql.Data.EntityFramework.CodeFirTests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1")]
+
+[assembly: NonParallelizable]
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProviderManifestTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProviderManifestTests.cs
index e99d76b52..aae8e618c 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProviderManifestTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/ProviderManifestTests.cs
@@ -1,103 +1,103 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using System;
-using MySql.Data.MySqlClient;
-using System.Data.Entity.Core.Metadata.Edm;
-using NUnit.Framework;
-
-namespace MySql.Data.EntityFramework.Tests
-{
- public class ProviderManifestTests : DefaultFixture
- {
- [Test]
- public void TestingMaxLengthFacet()
- {
- using (MySqlConnection connection = new MySqlConnection(ConnectionString))
- {
- MySqlProviderManifest pm = new MySqlProviderManifest(Version.ToString());
- TypeUsage tu = TypeUsage.CreateStringTypeUsage(
- PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false);
- TypeUsage result = pm.GetStoreType(tu);
- Assert.AreEqual("longtext", result.EdmType.Name);
-
- tu = TypeUsage.CreateStringTypeUsage(
- PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false, Int32.MaxValue);
- result = pm.GetStoreType(tu);
- Assert.AreEqual("longtext", result.EdmType.Name);
-
- tu = TypeUsage.CreateStringTypeUsage(
- PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false, 70000);
- result = pm.GetStoreType(tu);
- Assert.AreEqual("mediumtext", result.EdmType.Name);
-
- }
- }
-
- ///
- /// Bug #62135 Connector/NET Incorrectly Maps PrimitiveTypeKind.Byte to "tinyint"
- ///
- ///
+ /// Bug #62135 Connector/NET Incorrectly Maps PrimitiveTypeKind.Byte to "tinyint"
+ ///
+ /// (
- "SELECT VALUE b FROM Books AS b WHERE b.Pages > @pages",
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`,
- `Extent1`.`Author_Id` FROM `Books` AS `Extent1` WHERE `Extent1`.`Pages` > @pages",
- new ObjectParameter("pages", 200));
- }
-
- [Test]
- public void WhereLiteralOnRelation()
- {
- TestESql(
- "SELECT VALUE a FROM Authors AS a WHERE a.Address.City = 'Dallas'",
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`Age`, `Extent1`.`Address_City`,
- `Extent1`.`Address_Street`, `Extent1`.`Address_State`, `Extent1`.`Address_ZipCode`
- FROM `Authors` AS `Extent1` WHERE `Extent1`.`Address_City` = @gp1");
- }
-
- [Test]
- public void WhereWithRelatedEntities1()
- {
- TestESql(
- "SELECT VALUE b FROM Books AS b WHERE b.Author.Address.State = 'TX'",
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`,
- `Extent1`.`Author_Id` FROM `Books` AS `Extent1` INNER JOIN `Authors` AS `Extent2`
- ON `Extent1`.`Author_Id` = `Extent2`.`Id` WHERE `Extent2`.`Address_State` = @gp1");
- }
-
- [Test]
- public void Exists()
- {
- TestESql(
- @"SELECT VALUE a FROM Authors AS a WHERE EXISTS(
- SELECT b FROM a.Books AS b WHERE b.Pages > 200)",
- @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`Age`, `Extent1`.`Address_City`,
- `Extent1`.`Address_Street`, `Extent1`.`Address_State`, `Extent1`.`Address_ZipCode`
- FROM `Authors` AS `Extent1` WHERE EXISTS(SELECT 1 AS `C1` FROM `Books` AS `Extent2`
- WHERE (`Extent1`.`Id` = `Extent2`.`Author_Id`) AND (`Extent2`.`Pages` > 200))");
- }
- }
-}
\ No newline at end of file
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using System.Data.Entity.Core.Objects;
+using NUnit.Framework;
+
+namespace MySql.Data.EntityFramework.Tests
+{
+ public class RestrictionOperators : DefaultFixture
+ {
+ [Test]
+ public void SimpleSelectWithParam()
+ {
+ TestESql(
+ "SELECT VALUE b FROM Books AS b WHERE b.Pages > @pages",
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`,
+ `Extent1`.`Author_Id` FROM `Books` AS `Extent1` WHERE `Extent1`.`Pages` > @pages",
+ new ObjectParameter("pages", 200));
+ }
+
+ [Test]
+ public void WhereLiteralOnRelation()
+ {
+ TestESql(
+ "SELECT VALUE a FROM Authors AS a WHERE a.Address.City = 'Dallas'",
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`Age`, `Extent1`.`Address_City`,
+ `Extent1`.`Address_Street`, `Extent1`.`Address_State`, `Extent1`.`Address_ZipCode`
+ FROM `Authors` AS `Extent1` WHERE `Extent1`.`Address_City` = @gp1");
+ }
+
+ [Test]
+ public void WhereWithRelatedEntities1()
+ {
+ TestESql(
+ "SELECT VALUE b FROM Books AS b WHERE b.Author.Address.State = 'TX'",
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`PubDate`, `Extent1`.`Pages`,
+ `Extent1`.`Author_Id` FROM `Books` AS `Extent1` INNER JOIN `Authors` AS `Extent2`
+ ON `Extent1`.`Author_Id` = `Extent2`.`Id` WHERE `Extent2`.`Address_State` = @gp1");
+ }
+
+ [Test]
+ public void Exists()
+ {
+ TestESql(
+ @"SELECT VALUE a FROM Authors AS a WHERE EXISTS(
+ SELECT b FROM a.Books AS b WHERE b.Pages > 200)",
+ @"SELECT `Extent1`.`Id`, `Extent1`.`Name`, `Extent1`.`Age`, `Extent1`.`Address_City`,
+ `Extent1`.`Address_Street`, `Extent1`.`Address_State`, `Extent1`.`Address_ZipCode`
+ FROM `Authors` AS `Extent1` WHERE EXISTS(SELECT 1 AS `C1` FROM `Books` AS `Extent2`
+ WHERE (`Extent1`.`Id` = `Extent2`.`Author_Id`) AND (`Extent2`.`Pages` > 200))");
+ }
+ }
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SchemaInformation.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SchemaInformation.cs
index 6d5b4dbab..533520f5d 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SchemaInformation.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SchemaInformation.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SetOperators.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SetOperators.cs
index 2826cb2dc..831028559 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SetOperators.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SetOperators.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2020 Oracle and/or its affiliates.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -78,7 +78,7 @@ public void FirstSimple()
select p;
Product product = q.First() as Product;
- Assert.AreEqual(id, product.Id);
+ Assert.That(product.Id, Is.EqualTo(id));
}
}
@@ -94,8 +94,8 @@ public void FirstPredicate()
where p.MinAge > 8
select p;
Product product = q.First() as Product;
- Assert.AreEqual(id, product.Id);
+ Assert.That(product.Id, Is.EqualTo(id));
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SimpleQuery.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SimpleQuery.cs
index ee3e2c31e..5b5a5f857 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SimpleQuery.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/SimpleQuery.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2021, Oracle and/or its affiliates.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -84,8 +84,8 @@ public void TablesWithSchemaWithoutUsingProperty()
context.SaveChanges();
var q = (from u in context.User select u).ToArray();
- Assert.IsTrue(q.Length == 2);
+ Assert.That(q.Length == 2);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/UpdateTests.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/UpdateTests.cs
index df74ec178..887e14908 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/UpdateTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/UpdateTests.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -71,4 +71,4 @@ public void UpdateSimple()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Wizard.cs b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Wizard.cs
index 2d77db265..331db08b4 100644
--- a/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Wizard.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.Basic.Tests/Wizard.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
@@ -45,17 +45,17 @@ public void GetDbProviderManifestTokenReturnsCorrectSchemaVersion()
string token = services.GetProviderManifestToken(Connection);
if (Version < new Version(5, 1))
- Assert.AreEqual("5.0", token);
+ Assert.That(token, Is.EqualTo("5.0"));
else if (Version < new Version(5, 5))
- Assert.AreEqual("5.1", token);
+ Assert.That(token, Is.EqualTo("5.1"));
else if (Version < new Version(5, 6))
- Assert.AreEqual("5.5", token);
+ Assert.That(token, Is.EqualTo("5.5"));
else if (Version < new Version(5, 7))
- Assert.AreEqual("5.6", token);
+ Assert.That(token, Is.EqualTo("5.6"));
else if (Version < new Version(8, 0))
- Assert.AreEqual("5.7", token);
+ Assert.That(token, Is.EqualTo("5.7"));
else
- Assert.AreEqual("8.0", token);
+ Assert.That(token, Is.EqualTo("8.0"));
}
[Test]
@@ -64,8 +64,8 @@ public void GetStoreSchemaDescriptionDoesNotThrowForServer50OrGreater()
MySqlProviderManifest manifest = new MySqlProviderManifest(Version.Major + "." + Version.Minor);
using (XmlReader reader = manifest.GetInformation(DbXmlEnabledProviderManifest.StoreSchemaDefinition))
{
- Assert.NotNull(reader);
+ Assert.That(reader, Is.Not.Null);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/Blogs.cs b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/Blogs.cs
index 6cfb76543..46654e07f 100644
--- a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/Blogs.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/Blogs.cs
@@ -1,16 +1,16 @@
-// Copyright (c) 2020 Oracle and/or its affiliates.
+// Copyright © 2020, 2025, Oracle and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0, as
// published by the Free Software Foundation.
//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
// Without limiting anything contained in the foregoing, this file,
// which is part of MySQL Connector/NET, is also subject to the
diff --git a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstFixture.cs b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstFixture.cs
index 6702b1fa9..95fe2c649 100644
--- a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstFixture.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstFixture.cs
@@ -1,23 +1,29 @@
-// Copyright (c) 2013, 2021, Oracle and/or its affiliates.
+// Copyright © 2013, 2025, Oracle and/or its affiliates.
//
-// MySQL Connector/NET is licensed under the terms of the GPLv2
-// , like most
-// MySQL Connectors. There are special exceptions to the terms and
-// conditions of the GPLv2 as it is applied to this software, see the
-// FLOSS License Exception
-// .
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published
-// by the Free Software Foundation; version 2 of the License.
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-// for more details.
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
using MySql.Data.MySqlClient;
@@ -120,6 +126,7 @@ public CodeFirstFixture()
DeleteContext();
DeleteContext();
DeleteContext();
+ DeleteContext();
DeleteContext();
DeleteContext();
DeleteContext();
@@ -168,20 +175,20 @@ private EntityConnection GetEntityConnection()
foreach (char c in refSql)
if (!Char.IsWhiteSpace(c))
str2.Append(c);
- Assert.AreEqual(0, String.Compare(str1.ToString(), str2.ToString(), true));
+ Assert.That(String.Compare(str1.ToString(), str2.ToString(), true), Is.EqualTo(0));
}
private class AssertFailTraceListener : DefaultTraceListener
{
public override void Fail(string message)
{
- Assert.True(message == String.Empty, "Failure: " + message);
+ Assert.That(message == String.Empty, "Failure: " + message);
}
public override void Fail(string message, string detailMessage)
{
- Assert.True(message == String.Empty, "Failure: " + message);
+ Assert.That(message == String.Empty, "Failure: " + message);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstTests.cs b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstTests.cs
index 96089b3f0..5796c3e1e 100644
--- a/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstTests.cs
+++ b/EntityFramework/tests/MySql.EntityFramework.CodeFirst.Tests/CodeFirstTests.cs
@@ -1,2254 +1,2292 @@
-// Copyright (c) 2014, 2023, Oracle and/or its affiliates.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0, as
-// published by the Free Software Foundation.
-//
-// This program is also distributed with certain software (including
-// but not limited to OpenSSL) that is licensed under separate terms,
-// as designated in a particular file or component or in included license
-// documentation. The authors of MySQL hereby grant you an
-// additional permission to link the program and your derivative works
-// with the separately licensed software that they have included with
-// MySQL.
-//
-// Without limiting anything contained in the foregoing, this file,
-// which is part of MySQL Connector/NET, is also subject to the
-// Universal FOSS Exception, version 1.0, a copy of which can be found at
-// http://oss.oracle.com/licenses/universal-foss-exception.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License, version 2.0, for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-using MySql.Data.EntityFramework.Tests;
-using MySql.Data.MySqlClient;
-using MySql.EntityFramework.CodeFirst.Tests;
-using MySql.EntityFramework.CodeFirst.Tests.Properties;
-using NUnit.Framework;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Entity;
-using System.Data.Entity.Infrastructure;
-using System.Data.Entity.Spatial;
-using System.Diagnostics;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading;
-
-namespace MySql.Data.EntityFramework.CodeFirst.Tests
-{
- public class CodeFirstTests : CodeFirstFixture
- {
- ///
- /// Tests for fix of http://bugs.mysql.com/bug.php?id=61230
- /// ("The provider did not return a ProviderManifestToken string.").
- ///
- [Test]
- public void SimpleCodeFirstSelect()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- var l = db.Movies.ToList();
- int j = l.Count;
- foreach (var i in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
-
- ///
- /// Tests for fix of http://bugs.mysql.com/bug.php?id=62150
- /// ("EF4.1, Code First, CreateDatabaseScript() generates an invalid MySQL script.").
- ///
- [Test]
- public void AlterTableTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- var l = db.MovieFormats.ToList();
- int j = l.Count;
- foreach (var i in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- MovieFormat m = new MovieFormat();
- m.Format = 8.0f;
- db.MovieFormats.Add(m);
- db.SaveChanges();
- MovieFormat m2 = db.MovieFormats.Where(p => p.Format == 8.0f).FirstOrDefault();
- Assert.NotNull(m2);
- Assert.AreEqual(8.0f, m2.Format);
- }
-
- ///
- /// Fix for "Connector/Net Generates Incorrect SELECT Clause after UPDATE" (MySql bug #62134, Oracle bug #13491689).
- ///
- [Test]
- public void ConcurrencyCheckWithNonDbGeneratedColumn()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Delete();
- db.Database.CreateIfNotExists();
- MovieDBInitialize.DoDataPopulation(db);
- db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases`");
-
- db.Database.ExecuteSqlCommand(
-@"CREATE TABLE IF NOT EXISTS `MovieReleases` (
- `Id` int(11) NOT NULL,
- `Name` varbinary(45) NOT NULL,
- `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`Id`)
-) ENGINE=InnoDB DEFAULT CHARSET=binary");
- MySqlTrace.Listeners.Clear();
- MySqlTrace.Switch.Level = SourceLevels.All;
- GenericListener listener = new GenericListener();
- MySqlTrace.Listeners.Add(listener);
- try
- {
- MovieRelease mr = db.MovieReleases.Create();
- mr.Id = 1;
- mr.Name = "Commercial";
- db.MovieReleases.Add(mr);
- db.SaveChanges();
- mr.Name = "Director's Cut";
- db.SaveChanges();
- }
- finally
- {
- db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases`");
- }
- // Check sql
- Regex rx = new Regex(@"Query Opened: (?- UPDATE .*)", RegexOptions.Compiled | RegexOptions.Singleline);
- foreach (string s in listener.Strings)
- {
- Match m = rx.Match(s);
- if (m.Success)
- {
- CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelectWithNonDbGeneratedLock);
- //Assert.Pass();
- }
- }
- //Assert.Fail();
- }
- }
-
- ///
- /// This tests fix for http://bugs.mysql.com/bug.php?id=64216.
- ///
- [Test]
- public void CheckByteArray()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- string dbCreationScript =
- ((IObjectContextAdapter)db).ObjectContext.CreateDatabaseScript();
- Regex rx = new Regex(@"`Data` (?[^\),]*)", RegexOptions.Compiled | RegexOptions.Singleline);
- Match m = rx.Match(dbCreationScript);
- Assert.AreEqual("longblob", m.Groups["type"].Value);
- }
-
- ///
- /// Validates a stored procedure call using Code First
- /// Bug #14008699
- [Test]
- public void CallStoredProcedure()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext context = new MovieDBContext())
- {
- context.Database.Initialize(true);
- context.Database.ExecuteSqlCommand(@"drop procedure if exists `GetCount`");
- context.Database.ExecuteSqlCommand(@"create procedure `GetCount`() begin select 5; end;");
- long count = context.Database.SqlQuery("call GetCount").First();
-
- Assert.AreEqual(5, count);
- }
- }
-
- ///
- /// Tests for fix of http://bugs.mysql.com/bug.php?id=63920
- /// Maxlength error when it's used code-first and inheritance (discriminator generated column)
- ///
- [Test]
- public void Bug63920_Test1()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (VehicleDbContext context = new VehicleDbContext())
- {
- context.Database.Delete();
- context.Database.Initialize(true);
-
- context.Vehicles.Add(new Car { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car" });
- context.Vehicles.Add(new Bike { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike" });
- context.SaveChanges();
-
- var list = context.Vehicles.ToList();
-
- int records = -1;
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
- MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Vehicles", conn);
- records = Convert.ToInt32(cmd.ExecuteScalar());
- }
-
- Assert.AreEqual(context.Vehicles.Count(), records);
- }
- }
-
- ///
- /// Tests for fix of http://bugs.mysql.com/bug.php?id=63920
- /// Key reference generation script error when it's used code-first and a single table for the inherited models
- ///
- [Test]
- public void Bug63920_Test2()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (VehicleDbContext2 context = new VehicleDbContext2())
- {
- context.Database.Delete();
- context.Database.Initialize(true);
-
- context.Vehicles.Add(new Car2 { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car" });
- context.Vehicles.Add(new Bike2 { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike" });
- context.SaveChanges();
-
- var list = context.Vehicles.ToList();
-
- int records = -1;
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
- MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Vehicle2", conn);
- records = Convert.ToInt32(cmd.ExecuteScalar());
- }
-
- Assert.AreEqual(context.Vehicles.Count(), records);
- }
- }
-
- ///
- /// This test fix for precision customization for columns bug (http://bugs.mysql.com/bug.php?id=65001),
- /// Trying to customize column precision in Code First does not work).
- ///
- [Test]
- [Ignore("Fix this")]
- public void TestPrecisionNscale()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- var l = db.Movies.ToList();
- using (MySqlDataReader r = new MySqlCommand($@"select numeric_precision, numeric_scale from information_schema.columns
-where table_schema = '{Connection.Database}' and table_name = 'movies' and column_name = 'Price'", Connection).ExecuteReader())
- {
- r.Read();
- Assert.AreEqual(16, r.GetInt32(0));
- Assert.AreEqual(2, r.GetInt32(1));
- }
- }
-
- ///
- /// Test String types to StoreType for String
- /// A string with FixedLength=true will become a char
- /// Max Length left empty will be char(max)
- /// Max Length(100) will be char(100)
- /// while FixedLength=false will result in nvarchar.
- /// Max Length left empty will be nvarchar(max)
- /// Max Length(100) will be nvarchar(100)
- ///
- [Test]
- public void TestStringTypeToStoreType()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (VehicleDbContext3 context = new VehicleDbContext3())
- {
- if (context.Database.Exists()) context.Database.Delete();
- context.Database.CreateIfNotExists();
- context.Accessories.Add(new Accessory { Name = "Accesory One", Description = "Accesories descriptions", LongDescription = "Some long description" });
- context.SaveChanges();
-
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
- MySqlCommand query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='Description'", conn);
- query.Connection = conn;
- MySqlDataReader reader = query.ExecuteReader();
- while (reader.Read())
- {
- Assert.AreEqual("Description", reader[0].ToString());
- Assert.AreEqual("NO", reader[1].ToString());
- Assert.AreEqual("mediumtext", reader[2].ToString());
- }
- reader.Close();
-
- query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, character_maximum_length from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='Name'", conn);
- reader = query.ExecuteReader();
- while (reader.Read())
- {
- Assert.AreEqual("Name", reader[0].ToString());
- Assert.AreEqual("NO", reader[1].ToString());
- Assert.AreEqual("varchar", reader[2].ToString());
- Assert.AreEqual("255", reader[3].ToString());
- }
- reader.Close();
-
- query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, character_maximum_length from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='LongDescription'", conn);
- reader = query.ExecuteReader();
- while (reader.Read())
- {
- Assert.AreEqual("LongDescription", reader[0].ToString());
- Assert.AreEqual("NO", reader[1].ToString());
- Assert.AreEqual("longtext", reader[2].ToString());
- Assert.AreEqual("4294967295", reader[3].ToString());
- }
- }
- }
- }
-
- ///
- /// Test fix for http://bugs.mysql.com/bug.php?id=66066 / http://clustra.no.oracle.com/orabugs/bug.php?id=14479715
- /// (Using EF, crash when generating insert with no values.).
- ///
- [Test]
- public void AddingEmptyRow()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext ctx = new MovieDBContext())
- {
- ctx.Database.Initialize(true);
- ctx.EntitySingleColumns.Add(new EntitySingleColumn());
- ctx.SaveChanges();
- }
-
- using (MovieDBContext ctx2 = new MovieDBContext())
- {
- var q = from esc in ctx2.EntitySingleColumns where esc.Id == 1 select esc;
- Assert.AreEqual(1, q.Count());
- }
- }
-
- ///
- /// Test for identity columns when type is Integer or Guid (auto-generate
- /// values)
- ///
- [Test]
- public void IdentityTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (VehicleDbContext context = new VehicleDbContext())
- {
- context.Database.ExecuteSqlCommand("SET GLOBAL sql_mode='STRICT_ALL_TABLES'");
- if (context.Database.Exists()) context.Database.Delete();
- context.Database.CreateIfNotExists();
-
- // Identity as Guid
- Manufacturer nissan = new Manufacturer
- {
- Name = "Nissan"
- };
- Manufacturer ford = new Manufacturer
- {
- Name = "Ford"
- };
- context.Manufacturers.Add(nissan);
- context.Manufacturers.Add(ford);
-
- // Identity as Integer
- Distributor dis1 = new Distributor
- {
- Name = "Distributor1"
- };
- Distributor dis2 = new Distributor
- {
- Name = "Distributor2"
- };
- context.Distributors.Add(dis1);
- context.Distributors.Add(dis2);
-
- context.SaveChanges();
-
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
-
- // Validates Guid
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM Manufacturers", conn);
- MySqlDataReader dr = cmd.ExecuteReader();
- Assert.False(!dr.HasRows, "No records found");
-
- while (dr.Read())
- {
- string name = dr.GetString(1);
- switch (name)
- {
- case "Nissan":
- Assert.AreEqual(dr.GetGuid(0), nissan.ManufacturerId);
- Assert.AreEqual(dr.GetGuid(2), nissan.GroupIdentifier);
- break;
- case "Ford":
- Assert.AreEqual(dr.GetGuid(0), ford.ManufacturerId);
- Assert.AreEqual(dr.GetGuid(2), ford.GroupIdentifier);
- break;
- default:
- //Assert.Fail();
- break;
- }
- }
- dr.Close();
-
- // Validates Integer
- cmd = new MySqlCommand("SELECT * FROM Distributors", conn);
- dr = cmd.ExecuteReader();
- if (!dr.HasRows)
- //Assert.Fail("No records found");
- while (dr.Read())
- {
- string name = dr.GetString(1);
- switch (name)
- {
- case "Distributor1":
- Assert.AreEqual(dr.GetInt32(0), dis1.DistributorId);
- break;
- case "Distributor2":
- Assert.AreEqual(dr.GetInt32(0), dis2.DistributorId);
- break;
- default:
- //Assert.Fail();
- break;
- }
- }
- dr.Close();
- }
- }
- }
-
- ///
- /// This test the fix for bug 67377.
- ///
- [Test]
- public void FirstOrDefaultNested()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext ctx = new MovieDBContext())
- {
- ctx.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(ctx);
- int DirectorId = 1;
- var q = ctx.Movies.Where(p => p.Director.ID == DirectorId).Select(p =>
- new
- {
- Id = p.ID,
- FirstMovieFormat = p.Formats.Count == 0 ? 0.0 : p.Formats.FirstOrDefault().Format
- });
- string sql = q.ToString();
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = q.Count();
- foreach (var r in q)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
- }
-
- ///
- /// This tests the fix for bug 73549, Generated Sql does not contain ORDER BY statement whose is requested by LINQ.
- ///
- [Test]
- public void FirstOrDefaultNestedWithOrderBy()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (SakilaDb db = new SakilaDb())
- {
- var q = from cu in db.customers
- let curAddr = db.addresses.OrderByDescending(p => p.address_id).Where(p => p.address_id == cu.address_id).FirstOrDefault()
- join sto in db.stores on cu.store_id equals sto.store_id
- orderby cu.customer_id descending
- select new
- {
- curAddr.city.country.country1
- };
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.FirstOrDefaultNestedWithOrderBy);
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = q.Count();
- foreach (var r in q)
- {
- //Debug.WriteLine( r.country1 );
- }
- Assert.AreEqual(599, j);
- }
- }
-
- ///
- /// SUPPORT FOR DATE TYPES WITH PRECISION
- ///
- [Test]
- public void CanDefineDatesWithPrecisionFor56()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
-
- if (Version < new Version(5, 6)) return;
-
- using (var db = new ProductsDbContext())
- {
- db.Database.Initialize(true);
- using (MySqlConnection conn = new MySqlConnection(db.Database.Connection.ConnectionString))
- {
- conn.Open();
- MySqlCommand query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Products' and column_name ='DateTimeWithPrecision'", conn);
- query.Connection = conn;
- MySqlDataReader reader = query.ExecuteReader();
- while (reader.Read())
- {
- Assert.AreEqual("DateTimeWithPrecision", reader[0].ToString());
- Assert.AreEqual("NO", reader[1].ToString());
- Assert.AreEqual("datetime", reader[2].ToString());
- Assert.AreEqual("3", reader[3].ToString());
- }
- reader.Close();
-
- query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Products' and column_name ='TimeStampWithPrecision'", conn);
- query.Connection = conn;
- reader = query.ExecuteReader();
- while (reader.Read())
- {
- Assert.AreEqual("TimeStampWithPrecision", reader[0].ToString());
- Assert.AreEqual("NO", reader[1].ToString());
- Assert.AreEqual("timestamp", reader[2].ToString());
- Assert.AreEqual("3", reader[3].ToString());
- }
- reader.Close();
- }
- db.Database.Delete();
- }
- }
-
- ///
- /// Orabug #15935094 SUPPORT FOR CURRENT_TIMESTAMP AS DEFAULT FOR DATETIME WITH EF
- ///
- [Test]
- [Ignore("Fix this")]
- public void CanDefineDateTimeAndTimestampWithIdentity()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- if (Version < new Version(5, 6)) return;
-
- using (var db = new ProductsDbContext())
- {
- db.Database.Initialize(true);
- MySqlConnection con = (MySqlConnection)db.Database.Connection;
- MySqlCommand cmd = new MySqlCommand("set session sql_mode = '';", con);
- con.Open();
- cmd.ExecuteNonQuery();
- con.Close();
-
- Product product = new Product
- {
- //Omitting Identity Columns
- DateTimeWithPrecision = DateTime.Now,
- TimeStampWithPrecision = DateTime.Now
- };
-
- db.Products.Add(product);
- db.SaveChanges();
-
- var updateProduct = db.Products.First();
- updateProduct.DateTimeWithPrecision = new DateTime(2012, 3, 18, 23, 9, 7, 6);
- db.SaveChanges();
-
- Assert.NotNull(db.Products.First().Timestamp);
- Assert.NotNull(db.Products.First().DateCreated);
- Assert.AreEqual(new DateTime(2012, 3, 18, 23, 9, 7, 6), db.Products.First().DateTimeWithPrecision);
- Assert.AreEqual(1, db.Products.Count());
- db.Database.Delete();
- }
- }
-
-
- ///
- /// Test of fix for bug Support for EntityFramework 4.3 Code First Generated Identifiers (MySql Bug #67285, Oracle bug #16286397).
- /// FKs are renamed to met http://dev.mysql.com/doc/refman/5.0/en/identifiers.html limitations.
- ///
- [Test]
- public void LongIdentifiersInheritanceTPT()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (DinosauriaDBContext db = new DinosauriaDBContext())
- {
- db.Database.Initialize(true);
- Tyrannosauridae ty = new Tyrannosauridae() { Id = 1, Name = "Genghis Rex", SpecieName = "TRex", Weight = 1000 };
- db.dinos.Add(ty);
- Oviraptorosauria ovi = new Oviraptorosauria() { Id = 2, EggsPerYear = 100, Name = "John the Velociraptor", SpecieName = "Oviraptor" };
- db.dinos.Add(ovi);
- db.SaveChanges();
- }
- }
-
-
- ///
- /// Test fix for http://bugs.mysql.com/bug.php?id=67183
- /// (Malformed Query while eager loading with EF 4 due to multiple projections).
- ///
- [Test]
- public void ShipTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (var context = new ShipContext())
- {
- context.Database.Initialize(true);
-
- var harbor = new Harbor
- {
- Ships = new HashSet
- {
- new Ship
- {
- CrewMembers = new HashSet
- {
- new CrewMember
- {
- Rank = new Rank { Description = "Rank A" },
- Clearance = new Clearance { Description = "Clearance A" },
- Description = "CrewMember A"
- },
- new CrewMember
- {
- Rank = new Rank { Description = "Rank B" },
- Clearance = new Clearance { Description = "Clearance B" },
- Description = "CrewMember B"
- }
- },
- Description = "Ship AB"
- },
- new Ship
- {
- CrewMembers = new HashSet
- {
- new CrewMember
- {
- Rank = new Rank { Description = "Rank C" },
- Clearance = new Clearance { Description = "Clearance C" },
- Description = "CrewMember C"
- },
- new CrewMember
- {
- Rank = new Rank { Description = "Rank D" },
- Clearance = new Clearance { Description = "Clearance D" },
- Description = "CrewMember D"
- }
- },
- Description = "Ship CD"
- }
- },
- Description = "Harbor ABCD"
- };
-
- context.Harbors.Add(harbor);
- context.SaveChanges();
- }
-
- using (var context = new ShipContext())
- {
- DbSet dbSet = context.Set();
- IQueryable query = dbSet;
- query = query.Include(entity => entity.Ships);
- query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers));
- query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers.Select(cm => cm.Rank)));
- query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers.Select(cm => cm.Clearance)));
-
- string[] data = new string[] {
- "1,Harbor ABCD,1,1,1,Ship AB,1,1,1,1,1,CrewMember A,1,Rank A,1,Clearance A",
- "1,Harbor ABCD,1,1,1,Ship AB,1,2,1,2,2,CrewMember B,2,Rank B,2,Clearance B",
- "1,Harbor ABCD,1,2,1,Ship CD,1,3,2,3,3,CrewMember C,3,Rank C,3,Clearance C",
- "1,Harbor ABCD,1,2,1,Ship CD,1,4,2,4,4,CrewMember D,4,Rank D,4,Clearance D"
- };
- Dictionary outData = new Dictionary();
-
- var sqlString = query.ToString();
- CheckSql(sqlString, SQLSyntax.ShipQueryMalformedDueMultipleProjecttionsCorrectedEF6);
- // see below for the generated SQL query
-
- var harbor = query.Single();
-
- foreach (var ship in harbor.Ships)
- {
- foreach (var crewMember in ship.CrewMembers)
- {
- outData.Add(string.Format(
- "{0},{1},1,{2},{3},{4},1,{5},{6},{7},{8},{9},{10},{11},{12},{13}",
- harbor.HarborId, harbor.Description, ship.ShipId, harbor.HarborId,
- ship.Description, crewMember.CrewMemberId, crewMember.ShipId, crewMember.RankId,
- crewMember.ClearanceId, crewMember.Description, crewMember.Rank.RankId,
- crewMember.Rank.Description, crewMember.Clearance.ClearanceId,
- crewMember.Clearance.Description), null);
- }
- }
- // check data integrity
- Assert.AreEqual(outData.Count, data.Length);
- for (int i = 0; i < data.Length; i++)
- {
- Assert.True(outData.ContainsKey(data[i]));
- }
- }
- }
-
- ///
- /// Tests fix for bug http://bugs.mysql.com/bug.php?id=68513, Error in LINQ to Entities query when using Distinct().Count().
- ///
- [Test]
- public void DistinctCount()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (SiteDbContext ctx = new SiteDbContext())
- {
- ctx.Database.Initialize(true);
- visitante v1 = new visitante() { nCdSite = 1, nCdVisitante = 1, sDsIp = "x1" };
- visitante v2 = new visitante() { nCdSite = 1, nCdVisitante = 2, sDsIp = "x2" };
- site s1 = new site() { nCdSite = 1, sDsTitulo = "MyNewsPage" };
- site s2 = new site() { nCdSite = 2, sDsTitulo = "MySearchPage" };
- ctx.Visitante.Add(v1);
- ctx.Visitante.Add(v2);
- ctx.Site.Add(s1);
- ctx.Site.Add(s2);
- ctx.SaveChanges();
-
- var q = (from vis in ctx.Visitante.Include("site")
- group vis by vis.nCdSite into g
- select new retorno
- {
- Key = g.Key,
- Online = g.Select(e => e.sDsIp).Distinct().Count()
- });
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.CountGroupBy);
- var q2 = q.ToList();
- foreach (var row in q2)
- {
- }
- }
- }
-
- ///
- /// Tests fix for bug http://bugs.mysql.com/bug.php?id=68513, Error in LINQ to Entities query when using Distinct().Count().
- ///
- [Test]
- public void DistinctCount2()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (SiteDbContext ctx = new SiteDbContext())
- {
- ctx.Database.Initialize(true);
- visitante v1 = new visitante() { nCdSite = 1, nCdVisitante = 1, sDsIp = "x1" };
- visitante v2 = new visitante() { nCdSite = 1, nCdVisitante = 2, sDsIp = "x2" };
- site s1 = new site() { nCdSite = 1, sDsTitulo = "MyNewsPage" };
- site s2 = new site() { nCdSite = 2, sDsTitulo = "MySearchPage" };
- pagina p1 = new pagina() { nCdPagina = 1, nCdVisitante = 1, sDsTitulo = "index.html" };
- ctx.Visitante.Add(v1);
- ctx.Visitante.Add(v2);
- ctx.Site.Add(s1);
- ctx.Site.Add(s2);
- ctx.Pagina.Add(p1);
- ctx.SaveChanges();
-
- var q = (from pag in ctx.Pagina.Include("visitante").Include("site")
- group pag by pag.visitante.nCdSite into g
- select new retorno
- {
- Key = g.Key,
- Online = g.Select(e => e.visitante.sDsIp).Distinct().Count()
- });
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.CountGroupBy2);
- var q2 = q.ToList();
- foreach (var row in q2)
- {
- }
- }
- }
-
- ///
- /// Tests fix for bug http://bugs.mysql.com/bug.php?id=65723, MySql Provider for EntityFramework produces "bad" SQL for OrderBy.
- ///
- [Test]
- public void BadOrderBy()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- DateTime filterDate = new DateTime(1986, 1, 1);
- var q = db.Movies.Where(p => p.ReleaseDate >= filterDate).
- OrderByDescending(p => p.ReleaseDate).Take(2);
- string sql = q.ToString();
- CheckSql(SQLSyntax.NestedOrderBy, sql);
- // Data integrity testing
- Movie[] data = new Movie[] {
- new Movie() { ID = 4, Title = "Star Wars, The Sith Revenge", ReleaseDate = new DateTime( 2005, 5, 19 ) },
- new Movie() { ID = 2, Title = "The Matrix", ReleaseDate = new DateTime( 1999, 3, 31 ) }
- };
- int i = 0;
- foreach (Movie m in q)
- {
- Assert.AreEqual(data[i].ID, m.ID);
- Assert.AreEqual(data[i].Title, m.Title);
- Assert.AreEqual(data[i].ReleaseDate, m.ReleaseDate);
- i++;
- }
- Assert.AreEqual(2, i);
- }
- }
-
- ///
- /// Tests fix for bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- string title = "T";
- var q = from m in db.Movies
- where m.Title.Contains(title)
- orderby m.ID descending
- select m;
- var q1 = q.Take(10);
- string sql = q1.ToString();
-
- CheckSql(SQLSyntax.QueryWithOrderByTakeContains, sql);
-
- int i = 0;
- foreach (var row in q1)
- {
- Assert.AreEqual(MovieDBInitialize.data[i].ID, row.ID);
- Assert.AreEqual(MovieDBInitialize.data[i].Title, row.Title);
- Assert.AreEqual(MovieDBInitialize.data[i].ReleaseDate, row.ReleaseDate);
- i++;
- }
- }
- }
-
- ///
- /// Tests fix for bug http://bugs.mysql.com/bug.php?id=69922, Unknown column Extent1...
- ///
- [Test]
- public void BadAliasTable()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (PromotionsDB db = new PromotionsDB())
- {
- db.Database.Initialize(true);
- DateTime now = DateTime.Now;
- var q = db
- .HomePromoes
- .Where(x =>
- x.Active
- &&
- (x.ActiveFrom == null || x.ActiveFrom <= now)
- &&
- (x.ActiveTo == null || x.ActiveTo >= now)
- )
- .OrderBy(x => x.DisplayOrder).Select(d => d);
- string sql = q.ToString();
- foreach (var row in q)
- {
- }
- }
- }
-
- ///
- /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake2()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- var q = db.Movies.
- Where(m => !string.IsNullOrEmpty(m.Title) && m.Title.Contains("x")).
- OrderByDescending(m => m.ID).
- Skip(1).
- Take(1);
- string sql = q.ToString();
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- List l = q.ToList();
- int j = l.Count;
- foreach (Movie m in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
- }
-
- ///
- /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake3()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- var q = db.Movies.
- Where(m => !string.IsNullOrEmpty(m.Title) && m.Title.Contains("x")).
- OrderByDescending(m => m.ID).
- Skip(1).
- Take(1).Select(m => new
- {
- Id = m.ID,
- CriticsScore = (
- m.Title == "Terminator 1" ? "Good" :
- m.Title == "Predator" ? "Sunday best, cheese" :
- m.Title == "The Matrix" ? "Really Good" :
- m.Title == "Star Wars, The Sith Revenge" ? "Really Good" : "Unknown")
- });
- string sql = q.ToString();
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = q.Count();
- foreach (var row in q)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
- }
-
- ///
- /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake4()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- bool q = db.Movies.Any(m => m.ReleaseDate.Year > 1985);
- // string sql = q.ToString();
- //#if DEBUG
- // Debug.WriteLine(sql);
- //#endif
- //foreach (var row in q)
- //{
- //}
- }
- }
-
- ///
- /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake5()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- // TODO: add subquery like
- // var shifts = Shifts.Where(s => !EmployeeShifts.Where(es => es.ShiftID == s.ShiftID).Any());
- bool q = db.Movies.Where(m => m.ReleaseDate.Month != 10).Any(m => m.ReleaseDate.Year > 1985);
- // string sql = q.ToString();
- //#if DEBUG
- // Debug.WriteLine(sql);
- //#endif
- // foreach (var row in q)
- // {
- // }
- }
- }
-
- ///
- /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
- ///
- [Test]
- public void BadContainsOrderByTake6()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- var q = from m in db.Movies
- where m.Title.Contains("x") && db.Medias.Where(mm => mm.Format == "Digital").Any()
- select m;
- string sql = q.ToString();
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = q.Count();
- foreach (var row in q)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
- }
-
- ///
- /// Test for Mysql Bug 70602: http://bugs.mysql.com/bug.php?id=70602
- ///
- [Test]
- public void AutoIncrementBug()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- AutoIncrementBugContext dbContext = new AutoIncrementBugContext();
-
- dbContext.Database.Initialize(true);
- dbContext.AutoIncrementBug.Add(new AutoIncrementBug() { Description = "Test" });
- dbContext.SaveChanges();
- using (var reader = MySqlHelper.ExecuteReader(dbContext.Database.Connection.ConnectionString,
- $"SHOW COLUMNS FROM {nameof(dbContext.AutoIncrementBug)}s WHERE UPPER(EXTRA) LIKE '%AUTO_INCREMENT%'"))
- {
- Assert.True(reader.HasRows);
- }
- dbContext.Database.Delete();
- }
-
- [Test]
- public void SimpleCodeFirstSelectCbc()
- {
- MovieCodedBasedConfigDBContext db = new MovieCodedBasedConfigDBContext();
- db.Database.Initialize(true);
- var l = db.Movies.ToList();
- foreach (var i in l)
- {
- Console.WriteLine(i);
- }
- }
-
- [Test]
- [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
- public void TestStoredProcedureMapping()
- {
- using (var db = new MovieCodedBasedConfigDBContext())
- {
- db.Database.Initialize(true);
- var movie = new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- };
-
- db.Movies.Add(movie);
- db.SaveChanges();
- movie.Genre = "Fiction";
- db.SaveChanges();
- db.Movies.Remove(movie);
- db.SaveChanges();
- }
- }
-
- [Test]
- public void MigrationHistoryConfigurationTest()
- {
- MovieCodedBasedConfigDBContext db = new MovieCodedBasedConfigDBContext();
- db.Database.Initialize(true);
- var l = db.Movies.ToList();
- foreach (var i in l)
- {
- }
- var result = MySqlHelper.ExecuteScalar($"server=localhost;User Id=root;database={db.Database.Connection.Database};logging=true; port=" + Port + ";", "SELECT COUNT(_MigrationId) FROM __MySqlMigrations;");
- Assert.AreEqual(1, int.Parse(result.ToString()));
- }
-
- [Test]
- public void DbSetRangeTest()
- {
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- Movie m1 = new Movie() { Title = "Terminator 1", ReleaseDate = new DateTime(1984, 10, 26) };
- Movie m2 = new Movie() { Title = "The Matrix", ReleaseDate = new DateTime(1999, 3, 31) };
- Movie m3 = new Movie() { Title = "Predator", ReleaseDate = new DateTime(1987, 6, 12) };
- Movie m4 = new Movie() { Title = "Star Wars, The Sith Revenge", ReleaseDate = new DateTime(2005, 5, 19) };
- db.Movies.AddRange(new Movie[] { m1, m2, m3, m4 });
- db.SaveChanges();
- var q = from m in db.Movies select m;
- Assert.AreEqual(4, q.Count());
- foreach (var row in q)
- {
- }
- db.Movies.RemoveRange(q.ToList());
- db.SaveChanges();
- var q2 = from m in db.Movies select m;
- Assert.AreEqual(0, q2.Count());
- }
- }
-
- [Test]
- public void EnumSupportTest()
- {
- using (var dbCtx = new EnumTestSupportContext())
- {
- dbCtx.Database.Initialize(true);
- dbCtx.SchoolSchedules.Add(new SchoolSchedule() { TeacherName = "Pako", Subject = SchoolSubject.History });
- dbCtx.SaveChanges();
-
- var schedule = (from s in dbCtx.SchoolSchedules
- where s.Subject == SchoolSubject.History
- select s).FirstOrDefault();
-
- Assert.AreNotEqual(null, schedule);
- Assert.AreEqual(SchoolSubject.History, schedule.Subject);
- }
- }
-
-
- [Test]
- [Ignore("This test needs MicrosoftSqlServer.Types which is not available for all the target frameworks.")]
- public void SpatialSupportTest()
- {
- using (var dbCtx = new JourneyContext())
- {
- dbCtx.Database.Initialize(true);
- dbCtx.MyPlaces.Add(new MyPlace()
- {
- name = "JFK INTERNATIONAL AIRPORT OF NEW YORK",
- location = DbGeometry.FromText("POINT(40.644047 -73.782291)"),
- });
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "ALLEY POND PARK",
- location = DbGeometry.FromText("POINT(40.745696 -73.742638)")
- });
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "CUNNINGHAM PARK",
- location = DbGeometry.FromText("POINT(40.735031 -73.768387)")
- });
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "QUEENS VILLAGE STATION",
- location = DbGeometry.FromText("POINT(40.717957 -73.736501)")
- });
- dbCtx.SaveChanges();
-
- var place = (from p in dbCtx.MyPlaces
- where p.name == "JFK INTERNATIONAL AIRPORT OF NEW YORK"
- select p).FirstOrDefault();
-
- var point = DbGeometry.FromText("POINT(40.717957 -73.736501)");
-
- var distance = (point.Distance(place.location) * 100);
-
- Assert.AreNotEqual(null, place);
- Assert.AreEqual(8.6944880240295852D, distance.Value);
-
- var points = from p in dbCtx.MyPlaces
- select new { name = p.name, location = p.location };
- foreach (var item in points)
- {
- var distanceX = DbGeometry.FromText("POINT(40.717957 -73.736501)").Distance(item.location) * 100;
- Assert.IsNotNull(distanceX);
- }
-
- foreach (MyPlace p in dbCtx.MyPlaces)
- dbCtx.MyPlaces.Remove(p);
- dbCtx.SaveChanges();
-
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "AGraphic Design Institute",
- location = DbGeometry.FromText(string.Format("POINT({0} {1})", -122.336106, 47.605049), 101)
- });
-
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "AGraphic Design Institute",
- location = DbGeometry.FromText("POINT(-123.336106 47.605049)", 102)
- });
-
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "BGraphic Design Institute",
- location = DbGeometry.FromText("POINT(-113.336106 47.605049)", 103)
- });
-
- dbCtx.MyPlaces.Add(new MyPlace
- {
- name = "Graphic Design Institute",
- location = DbGeometry.FromText(string.Format("POINT({0} {1})", 51.5, -1.28), 4326)
- });
- dbCtx.SaveChanges();
-
- var result = (from u in dbCtx.MyPlaces select u.location.CoordinateSystemId).ToList();
- foreach (var item in result)
- Assert.IsNotNull(item);
- var res = dbCtx.MyPlaces.OrderBy(q => q.name.Take(1).Skip(1).ToList());
- Assert.IsNotNull(res);
-
- var pointA1 = DbGeometry.FromText(string.Format("POINT(40.644047 -73.782291)"));
- var pointB1 = DbGeometry.FromText("POINT(40.717957 -73.736501)");
- var distance1 = pointA1.Distance(pointB1);
-
- var pointA2 = DbGeometry.FromText("POINT(2.5 2.5)");
- var pointB2 = DbGeometry.FromText("POINT(4 0.8)");
- var distance2 = pointA2.Distance(pointB2);
-
- var pointA3 = DbGeometry.FromText("POINT(3 -4)");
- var pointB3 = DbGeometry.FromText("POINT(-1 3)");
- var distance3 = pointA3.Distance(pointB3);
-
- Assert.True(distance1.Value == 0.086944880240295855 && distance2.Value == 2.2671568097509267 &&
- distance3.Value == 8.06225774829855);
-
- }
- }
-
- [Test]
- public void BeginTransactionSupportTest()
- {
- using (var dbcontext = new MovieCodedBasedConfigDBContext())
- {
- dbcontext.Database.Initialize(true);
- using (var transaction = dbcontext.Database.BeginTransaction())
- {
- try
- {
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
-
- dbcontext.SaveChanges();
- var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true;port=" + Port + ";", "select COUNT(*) from moviecbcs;");
- Assert.AreEqual(0, int.Parse(result.ToString()));
-
- transaction.Commit();
-
- result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
- Assert.AreEqual(1, int.Parse(result.ToString()));
- }
- catch (Exception)
- {
- transaction.Rollback();
- }
- }
- }
- }
-
- ///
- /// This test covers two new features on EF6:
- /// 1- "DbContext.Database.UseTransaction, that use a transaction created from an open connection"
- /// 2- "DbContext can now be created with a DbConnection that is already opened"
- ///
- [Test]
- public void UseTransactionSupportTest()
- {
- using (var context = new MovieCodedBasedConfigDBContext())
- {
- context.Database.CreateIfNotExists();
- }
- using (var connection = new MySqlConnection($"server=localhost;User Id=root;database={nameof(MovieCodedBasedConfigDBContext)};logging=true; port=" + Port + ";"))
- {
- connection.Open();
- using (var transaction = connection.BeginTransaction())
- {
- try
- {
- using (var dbcontext = new MovieCodedBasedConfigDBContext(connection, contextOwnsConnection: false))
- {
- dbcontext.Database.Initialize(true);
- dbcontext.Database.UseTransaction(transaction);
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
-
- dbcontext.SaveChanges();
- }
- var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
- Assert.AreEqual(0, int.Parse(result.ToString()));
-
- transaction.Commit();
-
- result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
- Assert.AreEqual(1, int.Parse(result.ToString()));
- }
- catch (Exception)
- {
- transaction.Rollback();
- }
- }
- }
- }
-
- [Test]
- [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
- public void HasChangesSupportTest()
- {
- using (var dbcontext = new MovieCodedBasedConfigDBContext())
- {
- dbcontext.Database.Initialize(true);
-
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
-
- Assert.True(dbcontext.ChangeTracker.HasChanges());
- dbcontext.SaveChanges();
- Assert.False(dbcontext.ChangeTracker.HasChanges());
- }
- }
-
- [Test]
- [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
- public void MySqlLoggingToFileSupportTest()
- {
- string logName = "mysql.log";
- //if (System.IO.File.Exists(logName))
- // System.IO.File.Delete(logName);
-
- using (var dbcontext = new MovieCodedBasedConfigDBContext())
- {
- dbcontext.Database.Log = MySqlLogger.Logger(logName, true).Write;
-
- dbcontext.Database.Initialize(true);
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
- dbcontext.SaveChanges();
- }
-
- Assert.AreEqual(true, System.IO.File.Exists(logName));
- }
-
- [Test]
- [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
- public void MySqlLoggingToConsoleSupportTest()
- {
- string logName = "mysql_2.log";
- if (System.IO.File.Exists(logName))
- System.IO.File.Delete(logName);
-
- System.IO.FileStream file;
- System.IO.StreamWriter writer;
- System.IO.TextWriter txtOut = Console.Out;
- try
- {
- file = new System.IO.FileStream(logName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
- writer = new System.IO.StreamWriter(file);
- }
- catch (Exception e)
- {
- throw e;
- }
- Console.SetOut(writer);
-
- using (var dbcontext = new MovieCodedBasedConfigDBContext())
- {
- dbcontext.Database.Log = new MySqlLogger(s => Console.Write(s)).Write;
-
- dbcontext.Database.Initialize(true);
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
- dbcontext.SaveChanges();
- }
- Console.SetOut(txtOut);
- writer.Close();
- file.Close();
-
- Assert.AreEqual(true, System.IO.File.Exists(logName));
- }
-
- [Test]
- public void EntityAndComplexTypeSupportTest()
- {
- using (var dbContext = new EntityAndComplexTypeContext())
- {
- dbContext.Database.Initialize(true);
- dbContext.Students.Add(
- new Student()
- {
- Name = "Pakorasu Pakolas",
- Address = new Address() { City = "Mazatlan", Street = "Tierra de Venados 440" },
- Schedule = new List() { new SchoolSchedule() { TeacherName = "Pako", Subject = SchoolSubject.History } }
- });
- dbContext.SaveChanges();
-
- var student = (from s in dbContext.Students
- select s).FirstOrDefault();
-
- Assert.AreNotEqual(null, student);
- Assert.AreNotEqual(null, student.Schedule);
- Assert.AreNotEqual(true, string.IsNullOrEmpty(student.Address.Street));
- Assert.AreNotEqual(0, student.Schedule.Count());
- }
- }
-
- ///
- /// TO RUN THIS TEST ITS NECESSARY TO ENABLE THE EXECUTION STRATEGY IN THE CLASS MySqlEFConfiguration (Source\MySql.Data.Entity\MySqlConfiguration.cs) AS WELL AS START A MYSQL SERVER INSTACE WITH THE OPTION "--max_connections=3"
- /// WHY 3?: 1)For main process (User: root, DB: mysql). 2)For Setup Class. 3)For the connections in this test.
- /// The expected result is that opening a third connection and trying to open a fourth(with an asynchronous task) the execution strategy implementation handle the reconnection process until the third one is closed.
- ///
- //[Test] //<---DON'T FORGET ME TO RUN! =D
- public void ExecutionStrategyTest()
- {
- var connection = new MySqlConnection("server=localhost;User Id=root;logging=true; port=" + Port + ";");
- using (var dbcontext = new MovieCodedBasedConfigDBContext())
- {
- dbcontext.Database.Initialize(true);
- dbcontext.Movies.Add(new MovieCBC()
- {
- Title = "Sharknado",
- Genre = "Documental",
- Price = 1.50M,
- ReleaseDate = DateTime.Parse("01/07/2013")
- });
- connection.Open();
- System.Threading.Tasks.Task.Factory.StartNew(() => { dbcontext.SaveChanges(); });
- Thread.Sleep(1000);
- connection.Close();
- connection.Dispose();
- }
- var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
- Assert.AreEqual(1, int.Parse(result.ToString()));
- }
-
- [Test]
- public void UnknownProjectC1()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- long myKey = 20;
- var q = (from r in db.Movies where (r.ID == myKey) select (long)r.ID).OrderBy(p => p);
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.UnknownProjectC1EF6);
-
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- long[] array = (from r in db.Movies where (r.ID == myKey) select (long)r.ID).OrderBy(p => p).ToArray();
- }
- }
-
- [Test]
- public void StartsWithTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- string term = "The";
- var l = db.Movies.Where(p => p.Title.StartsWith(term));
-
- string sql = l.ToString();
-
- CheckSql(sql, SQLSyntax.QueryWithStartsWith);
-
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = l.Count();
- foreach (var i in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
-
- [Test]
- public void EndsWithTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- string term = "The";
- var l = db.Movies.Where(p => p.Title.EndsWith(term));
-
- string sql = l.ToString();
-
- CheckSql(sql, SQLSyntax.QueryWithEndsWith);
-
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = l.Count();
- foreach (var i in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
-
- [Test]
- public void ContainsTest()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- MovieDBContext db = new MovieDBContext();
- db.Database.Initialize(true);
- MovieDBInitialize.DoDataPopulation(db);
- string term = "The";
- var l = db.Movies.Where(p => p.Title.Contains(term));
-
- string sql = l.ToString();
- CheckSql(sql, SQLSyntax.QueryWithContains);
-
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- int j = l.Count();
- foreach (var i in l)
- {
- j--;
- }
- Assert.AreEqual(0, j);
- }
-
-
- ///
- /// Test to reproduce bug http://bugs.mysql.com/bug.php?id=73643, Exception when using IEnumera.Contains(model.property) in Where predicate
- ///
- [Test]
- public void TestContainsListWithCast()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
-
- long[] longs = new long[] { 1, 2, 3 };
- var q = db.Movies.Where(p => longs.Contains((long)p.ID));
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.TestContainsListWithCast);
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- var l = q.ToList();
- }
- }
-
- ///
- /// Test to reproduce bug http://bugs.mysql.com/bug.php?id=73643, Exception when using IEnumera.Contains(model.property) in Where predicate
- ///
- [Test]
- public void TestContainsListWitConstant()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
-
- List strIds = new List(new string[] { "two" });
- var q = db.Movies.Where(p => strIds.Contains("two"));
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.TestContainsListWitConstant);
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- var l = q.ToList();
- }
- }
-
- ///
- /// Test to reproduce bug http://bugs.mysql.com/bug.php?id=73643, Exception when using IEnumera.Contains(model.property) in Where predicate
- ///
- [Test]
- public void TestContainsListWithParameterReference()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Initialize(true);
-
- long[] longs = new long[] { 1, 2, 3 };
- int myNum = 1;
- var q = db.Movies.Where(p => longs.Contains(myNum));
- string sql = q.ToString();
- CheckSql(sql, SQLSyntax.TestContainsListWithParameterReference);
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- var l = q.ToList();
- }
- }
-
- [Test]
- public void ReplaceTableNameVisitor()
- {
- using (SakilaDb context = new SakilaDb())
- {
- var date = new DateTime(2005, 6, 1);
- var rentals = context.customers.Where(t => t.rentals.Any(r => r.rental_date < date)).OrderBy(o => o.customer_id);
- string sql = rentals.ToString();
- CheckSql(sql, SQLSyntax.ReplaceNameVisitorQuery);
-#if DEBUG
- Debug.WriteLine(sql);
-#endif
- var result = rentals.ToList();
- Assert.AreEqual(520, rentals.Count());
- }
- }
-
-
- ///
- /// Bug #70941 - Invalid SQL query when eager loading two nested collections
- ///
- [Test]
- public void InvalidQuery()
- {
- using (UsingUnionContext context = new UsingUnionContext())
- {
- if (context.Database.Exists())
- context.Database.Delete();
-
- context.Database.Create();
-
- for (int i = 1; i <= 3; i++)
- {
- var order = new Order();
- var items = new List
- ();
-
- items.Add(new Item { Id = 1 });
- items.Add(new Item { Id = 2 });
- items.Add(new Item { Id = 3 });
-
- order.Items = items;
- var client = new Client { Id = i };
- client.Orders = new List();
- client.Orders.Add(order);
-
- context.Clients.Add(client);
- }
- context.SaveChanges();
-
- var clients = context.Clients
- .Include(c => c.Orders.Select(o => o.Items))
- .Include(c => c.Orders.Select(o => o.Discounts)).ToList();
-
- Assert.AreEqual(clients.Count(), 3);
- Assert.AreEqual(clients.Where(t => t.Id == 1).Single().Orders.Count(), 1);
- Assert.AreEqual(clients.Where(t => t.Id == 1).Single().Orders.Where(j => j.Id == 1).Single().Items.Count(), 3);
- }
- }
-
- ///
- /// Bug #28095165 - CONTRIBUTION: FIX CONCURRENCYCHECK + DATABASEGENERATEDOPTION.COMPUTED
- ///
- [Test]
- public void ConcurrencyCheckWithDbGeneratedColumn()
- {
-#if DEBUG
- Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
-#endif
- using (MovieDBContext db = new MovieDBContext())
- {
- db.Database.Delete();
- db.Database.CreateIfNotExists();
- db.Database.Log = (e) => Debug.WriteLine(e);
- db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases2`");
-
- db.Database.ExecuteSqlCommand(
- @"CREATE TABLE IF NOT EXISTS `MovieRelease2` (
- `Id` int(11) NOT NULL,
- `Name` varchar(45) NOT NULL,
- `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- `RowVersion` bigint NOT NULL DEFAULT 0,
- PRIMARY KEY (`Id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=binary");
-
- db.Database.ExecuteSqlCommand(
- @"CREATE TRIGGER `trg_MovieRelease2_before_update`
- BEFORE UPDATE ON `MovieRelease2`
- FOR EACH ROW SET NEW.RowVersion = OLD.RowVersion + 1;");
-
- MySqlTrace.Listeners.Clear();
- MySqlTrace.Switch.Level = SourceLevels.All;
- GenericListener listener = new GenericListener();
- MySqlTrace.Listeners.Add(listener);
-
- try
- {
- MovieRelease2 mr = db.MovieReleases2.Create();
- mr.Id = 1;
- mr.Name = "Commercial";
- db.MovieReleases2.Add(mr);
- Assert.AreEqual(mr.RowVersion, 0);
- db.SaveChanges(); // ADD
- Assert.AreEqual(mr.RowVersion, 0);
-
- mr.Name = "Director's Cut";
- db.SaveChanges(); // UPDATE #1
- Assert.AreEqual(mr.RowVersion, 1);
-
- mr.Name = "Avengers";
- db.SaveChanges(); // UPDATE #2
- Assert.AreEqual(mr.RowVersion, 2);
- }
- finally
- {
- db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases2`");
- }
- // Check sql
- Regex rx = new Regex(@"Query Opened: (?
- UPDATE .*)", RegexOptions.Compiled | RegexOptions.Singleline);
- int n = 0;
- foreach (string s in listener.Strings)
- {
- Match m = rx.Match(s);
- if (m.Success)
- {
- if (n++ == 0)
- {
- CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelectWithDbGeneratedLock1);
- }
- else
- {
- CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelectWithDbGeneratedLock2);
- }
- }
- }
- }
- }
-
- ///
- /// Bug #31323788 - EF6 CODE FIRST - TABLE SCHEMAS ARE LOST, BUT AUTOMATIC MIGRATIONS USES THEM
- ///
- [Test]
- public void TablesWithSchema()
- {
- using (BlogContext context = new BlogContext())
- {
- var blog = new Blog { Title = "Blog_1" };
- context.Blog.Add(blog);
-
- blog = new Blog { Title = "Blog_2" };
- context.Blog.Add(blog);
-
- context.SaveChanges();
- Assert.AreEqual(2, context.Blog.Count());
- Assert.AreEqual(2, context.Blog.First(b => b.Title == "Blog_2").BlogId);
-
- context.Blog.Remove(blog);
- context.SaveChanges();
- Assert.AreEqual(1, context.Blog.Count());
- Assert.AreEqual("Blog_1", context.Blog.First().Title);
- }
- }
-
- [Test, Description("UNION SYNTAX MISSING REQUIRED PARENTHESIS")]
- public void UnionSyntax()
- {
- using (var context = new ContextForString())
- {
- context.Database.Delete();
- context.Database.Create();
- context.StringUsers.Add(new StringUser
- {
- StringUserId = 1,
- Name50 = "Juan",
- Name100 = "100",
- Name200 = "200",
- Name300 = "300"
- });
- context.StringUsers.Add(new StringUser
- {
- StringUserId = 2,
- Name50 = "Pedro",
- Name100 = "cien",
- Name200 = "doscientos",
- Name300 = "trescientos"
- });
- context.StringUsers.Add(new StringUser
- {
- StringUserId = 3,
- Name50 = "Lupe",
- Name100 = "101",
- Name200 = "cxvbx",
- Name300 = "301"
- });
- context.StringUsers.Add(new StringUser
- {
- StringUserId = 4,
- Name50 = "Luis",
- Name100 = "asdf",
- Name200 = "wrwe",
- Name300 = "xcvb"
- });
- context.StringUsers.Add(new StringUser
- {
- StringUserId = 5,
- Name50 = "Pepe",
- Name100 = "asdf",
- Name200 = "zxvz",
- Name300 = "fgsd"
- });
- context.SaveChanges();
-
- var query1 = context.StringUsers;
- var query2 = query1.Take(0).Concat(query1);
- var query3 = query1.Concat(query1.Take(0));
- Assert.True((query1.Count() == 5) & (query2.Count() == 5) & (query3.Count() == 5));
- }
- }
-
- [Test, Description("FK name ,longer than 64 chars are named to FK_")]
- public void NormalForeignKey()
- {
- using (var context = new ContextForNormalFk())
- {
- context.Database.Initialize(true);
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
- var cmd = new MySqlCommand();
- var entityName = (context.Permisos.GetType().FullName.Split(',')[0]).Substring(66).ToLowerInvariant();
- var contextName = context.GetType().Name.ToLowerInvariant();
- cmd.Connection = conn;
- cmd.CommandText =
- $"SELECT CONSTRAINT_NAME FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = '{contextName}' and TABLE_NAME = '{entityName}';";
- cmd.ExecuteNonQuery();
-
- using (var reader = cmd.ExecuteReader())
- {
- while (reader.Read())
- {
- var val = reader.GetValue(0);
- Assert.True(val.ToString().Contains("FK_"));
- }
- }
- }
- }
- }
-
- [Test, Description("FK name ,longer than 64 chars are named to FK_")]
- public void LongForeignKey()
- {
- using (var context = new ContextForLongFk())
- {
- context.Database.Initialize(true);
- var entityName = (context.Permisos.GetType().FullName.Split(',')[0]).Substring(66).ToLowerInvariant();
- var contextName = context.GetType().Name.ToLowerInvariant();
- using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
- {
- conn.Open();
- var cmd = new MySqlCommand();
- cmd.Connection = conn;
- cmd.CommandText =
- $"SELECT CONSTRAINT_NAME FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = '{contextName}' and TABLE_NAME = '{entityName}';";
- cmd.ExecuteNonQuery();
-
- using (var reader = cmd.ExecuteReader())
- {
- while (reader.Read())
- {
- var val = reader.GetValue(0);
- Assert.True(val.ToString().Contains("FK_"));
- }
- }
- }
- }
- }
-
- [Test, Description("Verify that Null Reference Exception is not thrown when try to save entity with TINYINT AS PK ")]
- public void SaveTinyIntAsPK()
- {
- using (var context = new ContextForTinyPk())
- {
- context.Database.Delete();
- context.Database.Create();
- context.TinyPkUseRs.Add(new TinyPkUser
- {
- StringUserId = 1,
- Name50 = "Juan",
- Name100 = "100",
- Name200 = "200",
- Name300 = "300"
- });
-
- context.TinyPkUseRs.Add(new TinyPkUser
- {
- StringUserId = 2,
- Name50 = "Pedro",
- Name100 = "cien",
- Name200 = "doscientos",
- Name300 = "trescientos"
- });
-
- context.TinyPkUseRs.Add(new TinyPkUser
- {
- StringUserId = 3,
- Name50 = "Lupe",
- Name100 = "101",
- Name200 = "cxvbx",
- Name300 = "301"
- });
-
- context.TinyPkUseRs.Add(new TinyPkUser
- {
- StringUserId = 4,
- Name50 = "Luis",
- Name100 = "asdf",
- Name200 = "wrwe",
- Name300 = "xcvb"
- });
-
- context.TinyPkUseRs.Add(new TinyPkUser
- {
- StringUserId = 5,
- Name50 = "Pepe",
- Name100 = "asdf",
- Name200 = "zxvz",
- Name300 = "fgsd"
- });
- context.SaveChanges();
- var query1 = context.TinyPkUseRs;
- var query2 = query1.Take(0).Concat(query1);
- var query3 = query1.Concat(query1.Take(0));
- Assert.True((query1.Count() == 5) & (query2.Count() == 5) & (query3.Count() == 5));
- }
- }
-
- [Test, Description("Verify that Null Reference Exception is not thrown when try to save entity with BIGINT AS PK ")]
- public void SaveBigIntAsPK()
- {
- using (var context = new ContextForBigIntPk())
- {
- context.Database.Delete();
- context.Database.Create();
- context.BigIntPkUseRs.Add(new BigIntPkUser
- {
- StringUserId = 934157136952,
- Name50 = "Juan",
- Name100 = "100",
- Name200 = "200",
- Name300 = "300"
- });
-
- context.BigIntPkUseRs.Add(new BigIntPkUser
- {
- StringUserId = 934157136953,
- Name50 = "Pedro",
- Name100 = "cien",
- Name200 = "doscientos",
- Name300 = "trescientos"
- });
-
- context.BigIntPkUseRs.Add(new BigIntPkUser
- {
- StringUserId = 9223372036854775807,
- Name50 = "Lupe",
- Name100 = "101",
- Name200 = "cxvbx",
- Name300 = "301"
- });
-
- context.BigIntPkUseRs.Add(new BigIntPkUser
- {
- StringUserId = 0,
- Name50 = "Luis",
- Name100 = "asdf",
- Name200 = "wrwe",
- Name300 = "xcvb"
- });
-
- context.BigIntPkUseRs.Add(new BigIntPkUser
- {
- StringUserId = -9223372036854775808,
- Name50 = "Pepe",
- Name100 = "asdf",
- Name200 = "zxvz",
- Name300 = "fgsd"
- });
- context.SaveChanges();
- var query1 = context.BigIntPkUseRs;
- var query2 = query1.Take(0).Concat(query1);
- var query3 = query1.Concat(query1.Take(0));
- Assert.True((query1.Count() == 5) & (query2.Count() == 5) & (query3.Count() == 5));
- }
- }
-
- [Test, Description("TRANSACTION AFTER A FAILED TRANSACTION((USING BeginTransaction)) Commit")]
- public void BeginTransNested()
- {
- using (var context = new EnumTestSupportContext())
- {
- using (var trans = context.Database.BeginTransaction())
- {
- Thread.Sleep(5000);
- Assert.Catch(() => context.Database.ExecuteSqlCommand("update table schoolschedule"));
- trans.Commit();
- }
- using (var trans = context.Database.BeginTransaction())
- {
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Ruben",
- Subject = SchoolSubject.History
- });
- ;
-
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Peter",
- Subject = SchoolSubject.Chemistry
- });
- ;
-
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Juan",
- Subject = SchoolSubject.Math
- });
- ;
- context.SaveChanges();
- trans.Commit();
- }
- var count = context.SchoolSchedules.Count();
- Assert.AreEqual(3, count);
- //Rollback
- using (var trans = context.Database.BeginTransaction())
- {
- Assert.Catch(() => context.Database.ExecuteSqlCommand("update table schoolschedule"));
- trans.Rollback();
- }
- using (var trans = context.Database.BeginTransaction())
- {
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Andrew",
- Subject = SchoolSubject.History
- }); ;
- ;
- context.SaveChanges();
- trans.Commit();
- }
- count = context.SchoolSchedules.Count();
- Assert.AreEqual(4, count);
- }
-
- }
-
- [Test, Description("TRANSACTION AFTER A FAILED TRANSACTION((USING BeginTransaction)) Stress Test")]
- public void TransactionAfterFailStressTest()
- {
- for (var i = 0; i < 100; i++)
- {
- using (var context = new EnumTestSupportContext())
- {
- using (var trans = context.Database.BeginTransaction())
- {
- Assert.Catch(() => context.Database.ExecuteSqlCommand("update table schoolschedule"));
- trans.Commit();
- }
- using (var trans = context.Database.BeginTransaction())
- {
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Ruben",
- Subject = SchoolSubject.History
- });
- ;
-
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Peter",
- Subject = SchoolSubject.Chemistry
- });
- ;
-
- context.SchoolSchedules.Add(new SchoolSchedule
- {
- TeacherName = "Juan",
- Subject = SchoolSubject.Math
- });
- context.SaveChanges();
- trans.Commit();
- var count = context.SchoolSchedules.Count();
- Assert.True(count > 0);
- }
- }
- }
- }
-
-
- [Test, Description("Wrong SQL Statement to set primary key ")]
- public void WrongSQLStatementPK()
- {
- using (var context = new EducationContext())
- {
- context.Database.Delete();
- context.Database.Create();
- context.Passports.Add(new Passport { Key = 1 });
- context.SaveChanges();
- context.Database.ExecuteSqlCommand("ALTER TABLE `passports` CHANGE `Key` `Key1` int NOT NULL AUTO_INCREMENT UNIQUE");
- context.Database.ExecuteSqlCommand("ALTER TABLE `passports` DROP PRIMARY KEY");
- }
-
- using (var context = new EducationContext())
- {
- context.Passports.Add(new Passport { Key = 1 });
- Exception ex = Assert.Catch(() => context.SaveChanges());
- context.Database.Delete();
- }
- }
-
- ///
- /// Bug #34498485 [MySQL.Data.EntityFramework does not handle LIKE (Edm.IndexOf) cases]
- ///
- [Test]
- public void TestListMatchingLike()
- {
- using (VehicleDbContext2 context = new VehicleDbContext2())
- {
- context.Database.Delete();
- context.Database.Initialize(true);
-
- context.Vehicles.Add(new Car2 { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car" });
- context.Vehicles.Add(new Bike2 { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike" });
- context.SaveChanges();
-
- string[] matchText = new string[] { "must", "tan" };
- var list = context.Vehicles.Where(v => matchText.Any(t => v.Name.Contains(t)));
- Assert.AreEqual(1, list.Count());
-
- matchText = new string[] { "mus't", "tan" };
- list = context.Vehicles.Where(v => matchText.Any(t => v.Name.Contains(t)));
- Assert.AreEqual(1, list.Count());
-
- matchText = new string[] { "%" };
- list = context.Vehicles.Where(v => matchText.Any(t => v.Name.Contains(t)));
- Assert.AreEqual(0, list.Count());
-
- matchText = new string[] { "tan" };
- list = context.Vehicles.Where(v => matchText.Any(t => v.Name.Contains(t)));
- Assert.AreEqual(1, list.Count());
-
- matchText = new string[] { "_" };
- list = context.Vehicles.Where(v => matchText.Any(t => v.Name.Contains(t)));
- Assert.AreEqual(0, list.Count());
- }
- }
- }
-}
\ No newline at end of file
+// Copyright © 2014, 2025, Oracle and/or its affiliates.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0, as
+// published by the Free Software Foundation.
+//
+// This program is designed to work with certain software (including
+// but not limited to OpenSSL) that is licensed under separate terms, as
+// designated in a particular file or component or in included license
+// documentation. The authors of MySQL hereby grant you an additional
+// permission to link the program and your derivative works with the
+// separately licensed software that they have either included with
+// the program or referenced in the documentation.
+//
+// Without limiting anything contained in the foregoing, this file,
+// which is part of MySQL Connector/NET, is also subject to the
+// Universal FOSS Exception, version 1.0, a copy of which can be found at
+// http://oss.oracle.com/licenses/universal-foss-exception.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License, version 2.0, for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+using MySql.Data.EntityFramework.Tests;
+using MySql.Data.MySqlClient;
+using MySql.EntityFramework.CodeFirst.Tests;
+using MySql.EntityFramework.CodeFirst.Tests.Properties;
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+using System.Data.Entity.Spatial;
+using System.Diagnostics;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+namespace MySql.Data.EntityFramework.CodeFirst.Tests
+{
+ public class CodeFirstTests : CodeFirstFixture
+ {
+ ///
+ /// Tests for fix of http://bugs.mysql.com/bug.php?id=61230
+ /// ("The provider did not return a ProviderManifestToken string.").
+ ///
+ [Test]
+ public void SimpleCodeFirstSelect()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ var l = db.Movies.ToList();
+ int j = l.Count;
+ foreach (var i in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+
+ ///
+ /// Tests for fix of http://bugs.mysql.com/bug.php?id=62150
+ /// ("EF4.1, Code First, CreateDatabaseScript() generates an invalid MySQL script.").
+ ///
+ [Test]
+ public void AlterTableTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ var l = db.MovieFormats.ToList();
+ int j = l.Count;
+ foreach (var i in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ MovieFormat m = new MovieFormat();
+ m.Format = 8.0f;
+ db.MovieFormats.Add(m);
+ db.SaveChanges();
+ MovieFormat m2 = db.MovieFormats.Where(p => p.Format == 8.0f).FirstOrDefault();
+ Assert.That(m2, Is.Not.Null);
+ Assert.That(m2.Format, Is.EqualTo(8.0f));
+ }
+
+ ///
+ /// Fix for "Connector/Net Generates Incorrect SELECT Clause after UPDATE" (MySql bug #62134, Oracle bug #13491689).
+ ///
+ [Test]
+ public void ConcurrencyCheckWithNonDbGeneratedColumn()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Delete();
+ db.Database.CreateIfNotExists();
+ MovieDBInitialize.DoDataPopulation(db);
+ db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases`");
+
+ db.Database.ExecuteSqlCommand(
+@"CREATE TABLE IF NOT EXISTS `MovieReleases` (
+ `Id` int(11) NOT NULL,
+ `Name` varbinary(45) NOT NULL,
+ `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`Id`)
+) ENGINE=InnoDB DEFAULT CHARSET=binary");
+ MySqlTrace.Listeners.Clear();
+ MySqlTrace.Switch.Level = SourceLevels.All;
+ GenericListener listener = new GenericListener();
+ MySqlTrace.Listeners.Add(listener);
+ try
+ {
+ MovieRelease mr = db.MovieReleases.Create();
+ mr.Id = 1;
+ mr.Name = "Commercial";
+ db.MovieReleases.Add(mr);
+ db.SaveChanges();
+ mr.Name = "Director's Cut";
+ db.SaveChanges();
+ }
+ finally
+ {
+ db.Database.ExecuteSqlCommand(@"DROP TABLE IF EXISTS `MovieReleases`");
+ }
+ // Check sql
+ Regex rx = new Regex(@"Query Opened: (?
- UPDATE .*)", RegexOptions.Compiled | RegexOptions.Singleline);
+ foreach (string s in listener.Strings)
+ {
+ Match m = rx.Match(s);
+ if (m.Success)
+ {
+ CheckSql(m.Groups["item"].Value, SQLSyntax.UpdateWithSelectWithNonDbGeneratedLock);
+ //Assert.Pass();
+ }
+ }
+ //Assert.Fail();
+ }
+ }
+
+ ///
+ /// This tests fix for http://bugs.mysql.com/bug.php?id=64216.
+ ///
+ [Test]
+ public void CheckByteArray()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ string dbCreationScript =
+ ((IObjectContextAdapter)db).ObjectContext.CreateDatabaseScript();
+ Regex rx = new Regex(@"`Data` (?[^\),]*)", RegexOptions.Compiled | RegexOptions.Singleline);
+ Match m = rx.Match(dbCreationScript);
+ Assert.That(m.Groups["type"].Value, Is.EqualTo("longblob"));
+ }
+
+ ///
+ /// Validates a stored procedure call using Code First
+ /// Bug #14008699
+ [Test]
+ public void CallStoredProcedure()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext context = new MovieDBContext())
+ {
+ context.Database.Initialize(true);
+ context.Database.ExecuteSqlCommand(@"drop procedure if exists `GetCount`");
+ context.Database.ExecuteSqlCommand(@"create procedure `GetCount`() begin select 5; end;");
+ long count = context.Database.SqlQuery("call GetCount").First();
+
+ Assert.That(count, Is.EqualTo(5));
+ }
+ }
+
+ ///
+ /// Tests for fix of http://bugs.mysql.com/bug.php?id=116028
+ /// Incorrect discriminator generated column values when it's used code-first, inheritance and in a join statement
+ ///
+ [Test]
+ public void Bug116028_Test1()
+ {
+ List vehicles;
+ using (VehicleDbContext4 context = new VehicleDbContext4())
+ {
+ context.Database.Delete();
+ context.Database.Initialize(true);
+ var manuf = context.Manufacturers.Add(new Manufacturer4 { Name = "ACME" });
+ context.Vehicles.Add(new Car4 { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car", Manufacturer = manuf });
+ context.Vehicles.Add(new Bike4 { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike", Manufacturer = manuf });
+ context.SaveChanges();
+
+ vehicles = context.Manufacturers.SelectMany(v => v.Vehicles).ToList();
+
+ int records = -1;
+ using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+ MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Vehicles", conn);
+ records = Convert.ToInt32(cmd.ExecuteScalar());
+ }
+
+ Assert.That(records, Is.EqualTo(context.Vehicles.Count()));
+ }
+ using (VehicleDbContext4 context = new VehicleDbContext4())
+ {
+ var vehiclesfromdb = context.Manufacturers.SelectMany(v => v.Vehicles).ToList();
+ Assert.That(vehiclesfromdb.OfType().Single().CarProperty, Is.EqualTo(vehicles.OfType().Single().CarProperty));
+ Assert.That(vehiclesfromdb.OfType().Single().BikeProperty, Is.EqualTo(vehicles.OfType().Single().BikeProperty));
+ }
+ }
+
+ ///
+ /// Tests for fix of http://bugs.mysql.com/bug.php?id=63920
+ /// Maxlength error when it's used code-first and inheritance (discriminator generated column)
+ ///
+ [Test]
+ public void Bug63920_Test1()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (VehicleDbContext context = new VehicleDbContext())
+ {
+ context.Database.Delete();
+ context.Database.Initialize(true);
+
+ context.Vehicles.Add(new Car { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car" });
+ context.Vehicles.Add(new Bike { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike" });
+ context.SaveChanges();
+
+ var list = context.Vehicles.ToList();
+
+ int records = -1;
+ using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+ MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Vehicles", conn);
+ records = Convert.ToInt32(cmd.ExecuteScalar());
+ }
+
+ Assert.That(records, Is.EqualTo(context.Vehicles.Count()));
+ }
+ }
+
+ ///
+ /// Tests for fix of http://bugs.mysql.com/bug.php?id=63920
+ /// Key reference generation script error when it's used code-first and a single table for the inherited models
+ ///
+ [Test]
+ public void Bug63920_Test2()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (VehicleDbContext2 context = new VehicleDbContext2())
+ {
+ context.Database.Delete();
+ context.Database.Initialize(true);
+
+ context.Vehicles.Add(new Car2 { Id = 1, Name = "Mustang", Year = 2012, CarProperty = "Car" });
+ context.Vehicles.Add(new Bike2 { Id = 101, Name = "Mountain", Year = 2011, BikeProperty = "Bike" });
+ context.SaveChanges();
+
+ var list = context.Vehicles.ToList();
+
+ int records = -1;
+ using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+ MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Vehicle2", conn);
+ records = Convert.ToInt32(cmd.ExecuteScalar());
+ }
+
+ Assert.That(records, Is.EqualTo(context.Vehicles.Count()));
+ }
+ }
+
+ ///
+ /// This test fix for precision customization for columns bug (http://bugs.mysql.com/bug.php?id=65001),
+ /// Trying to customize column precision in Code First does not work).
+ ///
+ [Test]
+ [Ignore("Fix this")]
+ public void TestPrecisionNscale()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ var l = db.Movies.ToList();
+ using (MySqlDataReader r = new MySqlCommand($@"select numeric_precision, numeric_scale from information_schema.columns
+where table_schema = '{Connection.Database}' and table_name = 'movies' and column_name = 'Price'", Connection).ExecuteReader())
+ {
+ r.Read();
+ Assert.That(r.GetInt32(0), Is.EqualTo(16));
+ Assert.That(r.GetInt32(1), Is.EqualTo(2));
+ }
+ }
+
+ ///
+ /// Test String types to StoreType for String
+ /// A string with FixedLength=true will become a char
+ /// Max Length left empty will be char(max)
+ /// Max Length(100) will be char(100)
+ /// while FixedLength=false will result in nvarchar.
+ /// Max Length left empty will be nvarchar(max)
+ /// Max Length(100) will be nvarchar(100)
+ ///
+ [Test]
+ public void TestStringTypeToStoreType()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (VehicleDbContext3 context = new VehicleDbContext3())
+ {
+ if (context.Database.Exists()) context.Database.Delete();
+ context.Database.CreateIfNotExists();
+ context.Accessories.Add(new Accessory { Name = "Accesory One", Description = "Accesories descriptions", LongDescription = "Some long description" });
+ context.SaveChanges();
+
+ using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+ MySqlCommand query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='Description'", conn);
+ query.Connection = conn;
+ MySqlDataReader reader = query.ExecuteReader();
+ while (reader.Read())
+ {
+ Assert.That(reader[0].ToString(), Is.EqualTo("Description"));
+ Assert.That(reader[1].ToString(), Is.EqualTo("NO"));
+ Assert.That(reader[2].ToString(), Is.EqualTo("mediumtext"));
+ }
+ reader.Close();
+
+ query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, character_maximum_length from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='Name'", conn);
+ reader = query.ExecuteReader();
+ while (reader.Read())
+ {
+ Assert.That(reader[0].ToString(), Is.EqualTo("Name"));
+ Assert.That(reader[1].ToString(), Is.EqualTo("NO"));
+ Assert.That(reader[2].ToString(), Is.EqualTo("varchar"));
+ Assert.That(reader[3].ToString(), Is.EqualTo("255"));
+ }
+ reader.Close();
+
+ query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, character_maximum_length from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Accessories' and column_name ='LongDescription'", conn);
+ reader = query.ExecuteReader();
+ while (reader.Read())
+ {
+ Assert.That(reader[0].ToString(), Is.EqualTo("LongDescription"));
+ Assert.That(reader[1].ToString(), Is.EqualTo("NO"));
+ Assert.That(reader[2].ToString(), Is.EqualTo("longtext"));
+ Assert.That(reader[3].ToString(), Is.EqualTo("4294967295"));
+ }
+ }
+ }
+ }
+
+ ///
+ /// Test fix for http://bugs.mysql.com/bug.php?id=66066 / http://clustra.no.oracle.com/orabugs/bug.php?id=14479715
+ /// (Using EF, crash when generating insert with no values.).
+ ///
+ [Test]
+ public void AddingEmptyRow()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext ctx = new MovieDBContext())
+ {
+ ctx.Database.Initialize(true);
+ ctx.EntitySingleColumns.Add(new EntitySingleColumn());
+ ctx.SaveChanges();
+ }
+
+ using (MovieDBContext ctx2 = new MovieDBContext())
+ {
+ var q = from esc in ctx2.EntitySingleColumns where esc.Id == 1 select esc;
+ Assert.That(q.Count(), Is.EqualTo(1));
+ }
+ }
+
+ ///
+ /// Test for identity columns when type is Integer or Guid (auto-generate
+ /// values)
+ ///
+ [Test]
+ public void IdentityTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (VehicleDbContext context = new VehicleDbContext())
+ {
+ context.Database.ExecuteSqlCommand("SET GLOBAL sql_mode='STRICT_ALL_TABLES'");
+ if (context.Database.Exists()) context.Database.Delete();
+ context.Database.CreateIfNotExists();
+
+ // Identity as Guid
+ Manufacturer nissan = new Manufacturer
+ {
+ Name = "Nissan"
+ };
+ Manufacturer ford = new Manufacturer
+ {
+ Name = "Ford"
+ };
+ context.Manufacturers.Add(nissan);
+ context.Manufacturers.Add(ford);
+
+ // Identity as Integer
+ Distributor dis1 = new Distributor
+ {
+ Name = "Distributor1"
+ };
+ Distributor dis2 = new Distributor
+ {
+ Name = "Distributor2"
+ };
+ context.Distributors.Add(dis1);
+ context.Distributors.Add(dis2);
+
+ context.SaveChanges();
+
+ using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+
+ // Validates Guid
+ MySqlCommand cmd = new MySqlCommand("SELECT * FROM Manufacturers", conn);
+ MySqlDataReader dr = cmd.ExecuteReader();
+ Assert.That(dr.HasRows, "No records found");
+
+ while (dr.Read())
+ {
+ string name = dr.GetString(1);
+ switch (name)
+ {
+ case "Nissan":
+ Assert.That(nissan.ManufacturerId, Is.EqualTo(dr.GetGuid(0)));
+ Assert.That(nissan.GroupIdentifier, Is.EqualTo(dr.GetGuid(2)));
+ break;
+ case "Ford":
+ Assert.That(ford.ManufacturerId, Is.EqualTo(dr.GetGuid(0)));
+ Assert.That(ford.GroupIdentifier, Is.EqualTo(dr.GetGuid(2)));
+ break;
+ default:
+ //Assert.Fail();
+ break;
+ }
+ }
+ dr.Close();
+
+ // Validates Integer
+ cmd = new MySqlCommand("SELECT * FROM Distributors", conn);
+ dr = cmd.ExecuteReader();
+ if (!dr.HasRows)
+ //Assert.Fail("No records found");
+ while (dr.Read())
+ {
+ string name = dr.GetString(1);
+ switch (name)
+ {
+ case "Distributor1":
+ Assert.That(dis1.DistributorId, Is.EqualTo(dr.GetInt32(0)));
+ break;
+ case "Distributor2":
+ Assert.That(dis2.DistributorId, Is.EqualTo(dr.GetInt32(0)));
+ break;
+ default:
+ //Assert.Fail();
+ break;
+ }
+ }
+ dr.Close();
+ }
+ }
+ }
+
+ ///
+ /// This test the fix for bug 67377.
+ ///
+ [Test]
+ public void FirstOrDefaultNested()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext ctx = new MovieDBContext())
+ {
+ ctx.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(ctx);
+ int DirectorId = 1;
+ var q = ctx.Movies.Where(p => p.Director.ID == DirectorId).Select(p =>
+ new
+ {
+ Id = p.ID,
+ FirstMovieFormat = p.Formats.Count == 0 ? 0.0 : p.Formats.FirstOrDefault().Format
+ });
+ string sql = q.ToString();
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = q.Count();
+ foreach (var r in q)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+ }
+
+ ///
+ /// This tests the fix for bug 73549, Generated Sql does not contain ORDER BY statement whose is requested by LINQ.
+ ///
+ [Test]
+ public void FirstOrDefaultNestedWithOrderBy()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (SakilaDb db = new SakilaDb())
+ {
+ var q = from cu in db.customers
+ let curAddr = db.addresses.OrderByDescending(p => p.address_id).Where(p => p.address_id == cu.address_id).FirstOrDefault()
+ join sto in db.stores on cu.store_id equals sto.store_id
+ orderby cu.customer_id descending
+ select new
+ {
+ curAddr.city.country.country1
+ };
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.FirstOrDefaultNestedWithOrderBy);
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = q.Count();
+ foreach (var r in q)
+ {
+ //Debug.WriteLine( r.country1 );
+ }
+ Assert.That(j, Is.EqualTo(599));
+ }
+ }
+
+ ///
+ /// SUPPORT FOR DATE TYPES WITH PRECISION
+ ///
+ [Test]
+ public void CanDefineDatesWithPrecisionFor56()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+
+ if (Version < new Version(5, 6)) return;
+
+ using (var db = new ProductsDbContext())
+ {
+ db.Database.Initialize(true);
+ using (MySqlConnection conn = new MySqlConnection(db.Database.Connection.ConnectionString))
+ {
+ conn.Open();
+ MySqlCommand query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Products' and column_name ='DateTimeWithPrecision'", conn);
+ query.Connection = conn;
+ MySqlDataReader reader = query.ExecuteReader();
+ while (reader.Read())
+ {
+ Assert.That(reader[0].ToString(), Is.EqualTo("DateTimeWithPrecision"));
+ Assert.That(reader[1].ToString(), Is.EqualTo("NO"));
+ Assert.That(reader[2].ToString(), Is.EqualTo("datetime"));
+ Assert.That(reader[3].ToString(), Is.EqualTo("3"));
+ }
+ reader.Close();
+
+ query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Products' and column_name ='TimeStampWithPrecision'", conn);
+ query.Connection = conn;
+ reader = query.ExecuteReader();
+ while (reader.Read())
+ {
+ Assert.That(reader[0].ToString(), Is.EqualTo("TimeStampWithPrecision"));
+ Assert.That(reader[1].ToString(), Is.EqualTo("NO"));
+ Assert.That(reader[2].ToString(), Is.EqualTo("timestamp"));
+ Assert.That(reader[3].ToString(), Is.EqualTo("3"));
+ }
+ reader.Close();
+ }
+ db.Database.Delete();
+ }
+ }
+
+ ///
+ /// Orabug #15935094 SUPPORT FOR CURRENT_TIMESTAMP AS DEFAULT FOR DATETIME WITH EF
+ ///
+ [Test]
+ [Ignore("Fix this")]
+ public void CanDefineDateTimeAndTimestampWithIdentity()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ if (Version < new Version(5, 6)) return;
+
+ using (var db = new ProductsDbContext())
+ {
+ db.Database.Initialize(true);
+ MySqlConnection con = (MySqlConnection)db.Database.Connection;
+ MySqlCommand cmd = new MySqlCommand("set session sql_mode = '';", con);
+ con.Open();
+ cmd.ExecuteNonQuery();
+ con.Close();
+
+ Product product = new Product
+ {
+ //Omitting Identity Columns
+ DateTimeWithPrecision = DateTime.Now,
+ TimeStampWithPrecision = DateTime.Now
+ };
+
+ db.Products.Add(product);
+ db.SaveChanges();
+
+ var updateProduct = db.Products.First();
+ updateProduct.DateTimeWithPrecision = new DateTime(2012, 3, 18, 23, 9, 7, 6);
+ db.SaveChanges();
+
+ Assert.That(db.Products.First().Timestamp, Is.Not.Empty);
+ Assert.That(db.Products.First().DateCreated, Is.Not.Empty);
+ Assert.That(db.Products.First().DateTimeWithPrecision, Is.EqualTo(new DateTime(2012, 3, 18, 23, 9, 7, 6)));
+ Assert.That(db.Products.Count(), Is.EqualTo(1));
+ db.Database.Delete();
+ }
+ }
+
+
+ ///
+ /// Test of fix for bug Support for EntityFramework 4.3 Code First Generated Identifiers (MySql Bug #67285, Oracle bug #16286397).
+ /// FKs are renamed to met http://dev.mysql.com/doc/refman/5.0/en/identifiers.html limitations.
+ ///
+ [Test]
+ public void LongIdentifiersInheritanceTPT()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (DinosauriaDBContext db = new DinosauriaDBContext())
+ {
+ db.Database.Initialize(true);
+ Tyrannosauridae ty = new Tyrannosauridae() { Id = 1, Name = "Genghis Rex", SpecieName = "TRex", Weight = 1000 };
+ db.dinos.Add(ty);
+ Oviraptorosauria ovi = new Oviraptorosauria() { Id = 2, EggsPerYear = 100, Name = "John the Velociraptor", SpecieName = "Oviraptor" };
+ db.dinos.Add(ovi);
+ db.SaveChanges();
+ }
+ }
+
+
+ ///
+ /// Test fix for http://bugs.mysql.com/bug.php?id=67183
+ /// (Malformed Query while eager loading with EF 4 due to multiple projections).
+ ///
+ [Test]
+ public void ShipTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (var context = new ShipContext())
+ {
+ context.Database.Initialize(true);
+
+ var harbor = new Harbor
+ {
+ Ships = new HashSet
+ {
+ new Ship
+ {
+ CrewMembers = new HashSet
+ {
+ new CrewMember
+ {
+ Rank = new Rank { Description = "Rank A" },
+ Clearance = new Clearance { Description = "Clearance A" },
+ Description = "CrewMember A"
+ },
+ new CrewMember
+ {
+ Rank = new Rank { Description = "Rank B" },
+ Clearance = new Clearance { Description = "Clearance B" },
+ Description = "CrewMember B"
+ }
+ },
+ Description = "Ship AB"
+ },
+ new Ship
+ {
+ CrewMembers = new HashSet
+ {
+ new CrewMember
+ {
+ Rank = new Rank { Description = "Rank C" },
+ Clearance = new Clearance { Description = "Clearance C" },
+ Description = "CrewMember C"
+ },
+ new CrewMember
+ {
+ Rank = new Rank { Description = "Rank D" },
+ Clearance = new Clearance { Description = "Clearance D" },
+ Description = "CrewMember D"
+ }
+ },
+ Description = "Ship CD"
+ }
+ },
+ Description = "Harbor ABCD"
+ };
+
+ context.Harbors.Add(harbor);
+ context.SaveChanges();
+ }
+
+ using (var context = new ShipContext())
+ {
+ DbSet dbSet = context.Set();
+ IQueryable query = dbSet;
+ query = query.Include(entity => entity.Ships);
+ query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers));
+ query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers.Select(cm => cm.Rank)));
+ query = query.Include(entity => entity.Ships.Select(s => s.CrewMembers.Select(cm => cm.Clearance)));
+
+ string[] data = new string[] {
+ "1,Harbor ABCD,1,1,1,Ship AB,1,1,1,1,1,CrewMember A,1,Rank A,1,Clearance A",
+ "1,Harbor ABCD,1,1,1,Ship AB,1,2,1,2,2,CrewMember B,2,Rank B,2,Clearance B",
+ "1,Harbor ABCD,1,2,1,Ship CD,1,3,2,3,3,CrewMember C,3,Rank C,3,Clearance C",
+ "1,Harbor ABCD,1,2,1,Ship CD,1,4,2,4,4,CrewMember D,4,Rank D,4,Clearance D"
+ };
+ Dictionary outData = new Dictionary();
+
+ var sqlString = query.ToString();
+ CheckSql(sqlString, SQLSyntax.ShipQueryMalformedDueMultipleProjecttionsCorrectedEF6);
+ // see below for the generated SQL query
+
+ var harbor = query.Single();
+
+ foreach (var ship in harbor.Ships)
+ {
+ foreach (var crewMember in ship.CrewMembers)
+ {
+ outData.Add(string.Format(
+ "{0},{1},1,{2},{3},{4},1,{5},{6},{7},{8},{9},{10},{11},{12},{13}",
+ harbor.HarborId, harbor.Description, ship.ShipId, harbor.HarborId,
+ ship.Description, crewMember.CrewMemberId, crewMember.ShipId, crewMember.RankId,
+ crewMember.ClearanceId, crewMember.Description, crewMember.Rank.RankId,
+ crewMember.Rank.Description, crewMember.Clearance.ClearanceId,
+ crewMember.Clearance.Description), null);
+ }
+ }
+ // check data integrity
+ Assert.That(data.Length, Is.EqualTo(outData.Count));
+ for (int i = 0; i < data.Length; i++)
+ {
+ Assert.That(outData.ContainsKey(data[i]));
+ }
+ }
+ }
+
+ ///
+ /// Tests fix for bug http://bugs.mysql.com/bug.php?id=68513, Error in LINQ to Entities query when using Distinct().Count().
+ ///
+ [Test]
+ public void DistinctCount()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (SiteDbContext ctx = new SiteDbContext())
+ {
+ ctx.Database.Initialize(true);
+ visitante v1 = new visitante() { nCdSite = 1, nCdVisitante = 1, sDsIp = "x1" };
+ visitante v2 = new visitante() { nCdSite = 1, nCdVisitante = 2, sDsIp = "x2" };
+ site s1 = new site() { nCdSite = 1, sDsTitulo = "MyNewsPage" };
+ site s2 = new site() { nCdSite = 2, sDsTitulo = "MySearchPage" };
+ ctx.Visitante.Add(v1);
+ ctx.Visitante.Add(v2);
+ ctx.Site.Add(s1);
+ ctx.Site.Add(s2);
+ ctx.SaveChanges();
+
+ var q = (from vis in ctx.Visitante.Include("site")
+ group vis by vis.nCdSite into g
+ select new retorno
+ {
+ Key = g.Key,
+ Online = g.Select(e => e.sDsIp).Distinct().Count()
+ });
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.CountGroupBy);
+ var q2 = q.ToList();
+ foreach (var row in q2)
+ {
+ }
+ }
+ }
+
+ ///
+ /// Tests fix for bug http://bugs.mysql.com/bug.php?id=68513, Error in LINQ to Entities query when using Distinct().Count().
+ ///
+ [Test]
+ public void DistinctCount2()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (SiteDbContext ctx = new SiteDbContext())
+ {
+ ctx.Database.Initialize(true);
+ visitante v1 = new visitante() { nCdSite = 1, nCdVisitante = 1, sDsIp = "x1" };
+ visitante v2 = new visitante() { nCdSite = 1, nCdVisitante = 2, sDsIp = "x2" };
+ site s1 = new site() { nCdSite = 1, sDsTitulo = "MyNewsPage" };
+ site s2 = new site() { nCdSite = 2, sDsTitulo = "MySearchPage" };
+ pagina p1 = new pagina() { nCdPagina = 1, nCdVisitante = 1, sDsTitulo = "index.html" };
+ ctx.Visitante.Add(v1);
+ ctx.Visitante.Add(v2);
+ ctx.Site.Add(s1);
+ ctx.Site.Add(s2);
+ ctx.Pagina.Add(p1);
+ ctx.SaveChanges();
+
+ var q = (from pag in ctx.Pagina.Include("visitante").Include("site")
+ group pag by pag.visitante.nCdSite into g
+ select new retorno
+ {
+ Key = g.Key,
+ Online = g.Select(e => e.visitante.sDsIp).Distinct().Count()
+ });
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.CountGroupBy2);
+ var q2 = q.ToList();
+ foreach (var row in q2)
+ {
+ }
+ }
+ }
+
+ ///
+ /// Tests fix for bug http://bugs.mysql.com/bug.php?id=65723, MySql Provider for EntityFramework produces "bad" SQL for OrderBy.
+ ///
+ [Test]
+ public void BadOrderBy()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ DateTime filterDate = new DateTime(1986, 1, 1);
+ var q = db.Movies.Where(p => p.ReleaseDate >= filterDate).
+ OrderByDescending(p => p.ReleaseDate).Take(2);
+ string sql = q.ToString();
+ CheckSql(SQLSyntax.NestedOrderBy, sql);
+ // Data integrity testing
+ Movie[] data = new Movie[] {
+ new Movie() { ID = 4, Title = "Star Wars, The Sith Revenge", ReleaseDate = new DateTime( 2005, 5, 19 ) },
+ new Movie() { ID = 2, Title = "The Matrix", ReleaseDate = new DateTime( 1999, 3, 31 ) }
+ };
+ int i = 0;
+ foreach (Movie m in q)
+ {
+ Assert.That(m.ID, Is.EqualTo(data[i].ID));
+ Assert.That(m.Title, Is.EqualTo(data[i].Title));
+ Assert.That(m.ReleaseDate, Is.EqualTo(data[i].ReleaseDate));
+ i++;
+ }
+ Assert.That(i, Is.EqualTo(2));
+ }
+ }
+
+ ///
+ /// Tests fix for bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ string title = "T";
+ var q = from m in db.Movies
+ where m.Title.Contains(title)
+ orderby m.ID descending
+ select m;
+ var q1 = q.Take(10);
+ string sql = q1.ToString();
+
+ CheckSql(SQLSyntax.QueryWithOrderByTakeContains, sql);
+
+ int i = 0;
+ foreach (var row in q1)
+ {
+ Assert.That(row.ID, Is.EqualTo(MovieDBInitialize.data[i].ID));
+ Assert.That(row.Title, Is.EqualTo(MovieDBInitialize.data[i].Title));
+ Assert.That(row.ReleaseDate, Is.EqualTo(MovieDBInitialize.data[i].ReleaseDate));
+ i++;
+ }
+ }
+ }
+
+ ///
+ /// Tests fix for bug http://bugs.mysql.com/bug.php?id=69922, Unknown column Extent1...
+ ///
+ [Test]
+ public void BadAliasTable()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (PromotionsDB db = new PromotionsDB())
+ {
+ db.Database.Initialize(true);
+ DateTime now = DateTime.Now;
+ var q = db
+ .HomePromoes
+ .Where(x =>
+ x.Active
+ &&
+ (x.ActiveFrom == null || x.ActiveFrom <= now)
+ &&
+ (x.ActiveTo == null || x.ActiveTo >= now)
+ )
+ .OrderBy(x => x.DisplayOrder).Select(d => d);
+ string sql = q.ToString();
+ foreach (var row in q)
+ {
+ }
+ }
+ }
+
+ ///
+ /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake2()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ var q = db.Movies.
+ Where(m => !string.IsNullOrEmpty(m.Title) && m.Title.Contains("x")).
+ OrderByDescending(m => m.ID).
+ Skip(1).
+ Take(1);
+ string sql = q.ToString();
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ List l = q.ToList();
+ int j = l.Count;
+ foreach (Movie m in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+ }
+
+ ///
+ /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake3()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ var q = db.Movies.
+ Where(m => !string.IsNullOrEmpty(m.Title) && m.Title.Contains("x")).
+ OrderByDescending(m => m.ID).
+ Skip(1).
+ Take(1).Select(m => new
+ {
+ Id = m.ID,
+ CriticsScore = (
+ m.Title == "Terminator 1" ? "Good" :
+ m.Title == "Predator" ? "Sunday best, cheese" :
+ m.Title == "The Matrix" ? "Really Good" :
+ m.Title == "Star Wars, The Sith Revenge" ? "Really Good" : "Unknown")
+ });
+ string sql = q.ToString();
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = q.Count();
+ foreach (var row in q)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+ }
+
+ ///
+ /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake4()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ bool q = db.Movies.Any(m => m.ReleaseDate.Year > 1985);
+ // string sql = q.ToString();
+ //#if DEBUG
+ // Debug.WriteLine(sql);
+ //#endif
+ //foreach (var row in q)
+ //{
+ //}
+ }
+ }
+
+ ///
+ /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake5()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ // TODO: add subquery like
+ // var shifts = Shifts.Where(s => !EmployeeShifts.Where(es => es.ShiftID == s.ShiftID).Any());
+ bool q = db.Movies.Where(m => m.ReleaseDate.Month != 10).Any(m => m.ReleaseDate.Year > 1985);
+ // string sql = q.ToString();
+ //#if DEBUG
+ // Debug.WriteLine(sql);
+ //#endif
+ // foreach (var row in q)
+ // {
+ // }
+ }
+ }
+
+ ///
+ /// Tests other variants of bug http://bugs.mysql.com/bug.php?id=69751, Invalid SQL query generated for query with Contains, OrderBy, and Take.
+ ///
+ [Test]
+ public void BadContainsOrderByTake6()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ var q = from m in db.Movies
+ where m.Title.Contains("x") && db.Medias.Where(mm => mm.Format == "Digital").Any()
+ select m;
+ string sql = q.ToString();
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = q.Count();
+ foreach (var row in q)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+ }
+
+ ///
+ /// Test for Mysql Bug 70602: http://bugs.mysql.com/bug.php?id=70602
+ ///
+ [Test]
+ public void AutoIncrementBug()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ AutoIncrementBugContext dbContext = new AutoIncrementBugContext();
+
+ dbContext.Database.Initialize(true);
+ dbContext.AutoIncrementBug.Add(new AutoIncrementBug() { Description = "Test" });
+ dbContext.SaveChanges();
+ using (var reader = MySqlHelper.ExecuteReader(dbContext.Database.Connection.ConnectionString,
+ $"SHOW COLUMNS FROM {nameof(dbContext.AutoIncrementBug)}s WHERE UPPER(EXTRA) LIKE '%AUTO_INCREMENT%'"))
+ {
+ Assert.That(reader.HasRows);
+ }
+ dbContext.Database.Delete();
+ }
+
+ [Test]
+ public void SimpleCodeFirstSelectCbc()
+ {
+ MovieCodedBasedConfigDBContext db = new MovieCodedBasedConfigDBContext();
+ db.Database.Initialize(true);
+ var l = db.Movies.ToList();
+ foreach (var i in l)
+ {
+ Console.WriteLine(i);
+ }
+ }
+
+ [Test]
+ [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
+ public void TestStoredProcedureMapping()
+ {
+ using (var db = new MovieCodedBasedConfigDBContext())
+ {
+ db.Database.Initialize(true);
+ var movie = new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ };
+
+ db.Movies.Add(movie);
+ db.SaveChanges();
+ movie.Genre = "Fiction";
+ db.SaveChanges();
+ db.Movies.Remove(movie);
+ db.SaveChanges();
+ }
+ }
+
+ [Test]
+ public void MigrationHistoryConfigurationTest()
+ {
+ MovieCodedBasedConfigDBContext db = new MovieCodedBasedConfigDBContext();
+ db.Database.Initialize(true);
+ var l = db.Movies.ToList();
+ foreach (var i in l)
+ {
+ }
+ var result = MySqlHelper.ExecuteScalar($"server=localhost;User Id=root;database={db.Database.Connection.Database};logging=true; port=" + Port + ";", "SELECT COUNT(_MigrationId) FROM __MySqlMigrations;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void DbSetRangeTest()
+ {
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ Movie m1 = new Movie() { Title = "Terminator 1", ReleaseDate = new DateTime(1984, 10, 26) };
+ Movie m2 = new Movie() { Title = "The Matrix", ReleaseDate = new DateTime(1999, 3, 31) };
+ Movie m3 = new Movie() { Title = "Predator", ReleaseDate = new DateTime(1987, 6, 12) };
+ Movie m4 = new Movie() { Title = "Star Wars, The Sith Revenge", ReleaseDate = new DateTime(2005, 5, 19) };
+ db.Movies.AddRange(new Movie[] { m1, m2, m3, m4 });
+ db.SaveChanges();
+ var q = from m in db.Movies select m;
+ Assert.That(q.Count(), Is.EqualTo(4));
+ foreach (var row in q)
+ {
+ }
+ db.Movies.RemoveRange(q.ToList());
+ db.SaveChanges();
+ var q2 = from m in db.Movies select m;
+ Assert.That(q2.Count(), Is.EqualTo(0));
+ }
+ }
+
+ [Test]
+ public void EnumSupportTest()
+ {
+ using (var dbCtx = new EnumTestSupportContext())
+ {
+ dbCtx.Database.Initialize(true);
+ dbCtx.SchoolSchedules.Add(new SchoolSchedule() { TeacherName = "Pako", Subject = SchoolSubject.History });
+ dbCtx.SaveChanges();
+
+ var schedule = (from s in dbCtx.SchoolSchedules
+ where s.Subject == SchoolSubject.History
+ select s).FirstOrDefault();
+
+ Assert.That(schedule, Is.Not.EqualTo(null));
+ Assert.That(schedule.Subject, Is.EqualTo(SchoolSubject.History));
+ }
+ }
+
+
+ [Test]
+ [Ignore("This test needs MicrosoftSqlServer.Types which is not available for all the target frameworks.")]
+ public void SpatialSupportTest()
+ {
+ using (var dbCtx = new JourneyContext())
+ {
+ dbCtx.Database.Initialize(true);
+ dbCtx.MyPlaces.Add(new MyPlace()
+ {
+ name = "JFK INTERNATIONAL AIRPORT OF NEW YORK",
+ location = DbGeometry.FromText("POINT(40.644047 -73.782291)"),
+ });
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "ALLEY POND PARK",
+ location = DbGeometry.FromText("POINT(40.745696 -73.742638)")
+ });
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "CUNNINGHAM PARK",
+ location = DbGeometry.FromText("POINT(40.735031 -73.768387)")
+ });
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "QUEENS VILLAGE STATION",
+ location = DbGeometry.FromText("POINT(40.717957 -73.736501)")
+ });
+ dbCtx.SaveChanges();
+
+ var place = (from p in dbCtx.MyPlaces
+ where p.name == "JFK INTERNATIONAL AIRPORT OF NEW YORK"
+ select p).FirstOrDefault();
+
+ var point = DbGeometry.FromText("POINT(40.717957 -73.736501)");
+
+ var distance = (point.Distance(place.location) * 100);
+
+ Assert.That(place, Is.Not.Null);
+ Assert.That(distance.Value, Is.EqualTo(8.6944880240295852D));
+
+ var points = from p in dbCtx.MyPlaces
+ select new { name = p.name, location = p.location };
+ foreach (var item in points)
+ {
+ var distanceX = DbGeometry.FromText("POINT(40.717957 -73.736501)").Distance(item.location) * 100;
+ Assert.That(distanceX, Is.Not.Null);
+ }
+
+ foreach (MyPlace p in dbCtx.MyPlaces)
+ dbCtx.MyPlaces.Remove(p);
+ dbCtx.SaveChanges();
+
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "AGraphic Design Institute",
+ location = DbGeometry.FromText(string.Format("POINT({0} {1})", -122.336106, 47.605049), 101)
+ });
+
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "AGraphic Design Institute",
+ location = DbGeometry.FromText("POINT(-123.336106 47.605049)", 102)
+ });
+
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "BGraphic Design Institute",
+ location = DbGeometry.FromText("POINT(-113.336106 47.605049)", 103)
+ });
+
+ dbCtx.MyPlaces.Add(new MyPlace
+ {
+ name = "Graphic Design Institute",
+ location = DbGeometry.FromText(string.Format("POINT({0} {1})", 51.5, -1.28), 4326)
+ });
+ dbCtx.SaveChanges();
+
+ var result = (from u in dbCtx.MyPlaces select u.location.CoordinateSystemId).ToList();
+ foreach (var item in result)
+ Assert.That(item, Is.Not.Empty);
+ var res = dbCtx.MyPlaces.OrderBy(q => q.name.Take(1).Skip(1).ToList());
+ Assert.That(res, Is.Not.Null);
+
+ var pointA1 = DbGeometry.FromText(string.Format("POINT(40.644047 -73.782291)"));
+ var pointB1 = DbGeometry.FromText("POINT(40.717957 -73.736501)");
+ var distance1 = pointA1.Distance(pointB1);
+
+ var pointA2 = DbGeometry.FromText("POINT(2.5 2.5)");
+ var pointB2 = DbGeometry.FromText("POINT(4 0.8)");
+ var distance2 = pointA2.Distance(pointB2);
+
+ var pointA3 = DbGeometry.FromText("POINT(3 -4)");
+ var pointB3 = DbGeometry.FromText("POINT(-1 3)");
+ var distance3 = pointA3.Distance(pointB3);
+
+ Assert.That(distance1.Value == 0.086944880240295855 && distance2.Value == 2.2671568097509267 &&
+ distance3.Value == 8.06225774829855);
+
+ }
+ }
+
+ [Test]
+ public void BeginTransactionSupportTest()
+ {
+ using (var dbcontext = new MovieCodedBasedConfigDBContext())
+ {
+ dbcontext.Database.Initialize(true);
+ using (var transaction = dbcontext.Database.BeginTransaction())
+ {
+ try
+ {
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+
+ dbcontext.SaveChanges();
+ var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true;port=" + Port + ";", "select COUNT(*) from moviecbcs;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(0));
+
+ transaction.Commit();
+
+ result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(1));
+ }
+ catch (Exception)
+ {
+ transaction.Rollback();
+ }
+ }
+ }
+ }
+
+ ///
+ /// This test covers two new features on EF6:
+ /// 1- "DbContext.Database.UseTransaction, that use a transaction created from an open connection"
+ /// 2- "DbContext can now be created with a DbConnection that is already opened"
+ ///
+ [Test]
+ public void UseTransactionSupportTest()
+ {
+ using (var context = new MovieCodedBasedConfigDBContext())
+ {
+ context.Database.CreateIfNotExists();
+ }
+ using (var connection = new MySqlConnection($"server=localhost;User Id=root;database={nameof(MovieCodedBasedConfigDBContext)};logging=true; port=" + Port + ";"))
+ {
+ connection.Open();
+ using (var transaction = connection.BeginTransaction())
+ {
+ try
+ {
+ using (var dbcontext = new MovieCodedBasedConfigDBContext(connection, contextOwnsConnection: false))
+ {
+ dbcontext.Database.Initialize(true);
+ dbcontext.Database.UseTransaction(transaction);
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+
+ dbcontext.SaveChanges();
+ }
+ var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(0));
+
+ transaction.Commit();
+
+ result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(1));
+ }
+ catch (Exception)
+ {
+ transaction.Rollback();
+ }
+ }
+ }
+ }
+
+ [Test]
+ [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
+ public void HasChangesSupportTest()
+ {
+ using (var dbcontext = new MovieCodedBasedConfigDBContext())
+ {
+ dbcontext.Database.Initialize(true);
+
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+
+ Assert.That(dbcontext.ChangeTracker.HasChanges());
+ dbcontext.SaveChanges();
+ Assert.That(!dbcontext.ChangeTracker.HasChanges());
+ }
+ }
+
+ [Test]
+ [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
+ public void MySqlLoggingToFileSupportTest()
+ {
+ string logName = "mysql.log";
+ //if (System.IO.File.Exists(logName))
+ // System.IO.File.Delete(logName);
+
+ using (var dbcontext = new MovieCodedBasedConfigDBContext())
+ {
+ dbcontext.Database.Log = MySqlLogger.Logger(logName, true).Write;
+
+ dbcontext.Database.Initialize(true);
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+ dbcontext.SaveChanges();
+ }
+
+ Assert.That(System.IO.File.Exists(logName), Is.EqualTo(true));
+ }
+
+ [Test]
+ [Ignore("Need to check. Bad statemen: CALL `MovieCodedBasedConfigDBContext`.``insert_movie``(@movie_name, @ReleaseDate, @Genre, @Price)")]
+ public void MySqlLoggingToConsoleSupportTest()
+ {
+ string logName = "mysql_2.log";
+ if (System.IO.File.Exists(logName))
+ System.IO.File.Delete(logName);
+
+ System.IO.FileStream file;
+ System.IO.StreamWriter writer;
+ System.IO.TextWriter txtOut = Console.Out;
+ try
+ {
+ file = new System.IO.FileStream(logName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
+ writer = new System.IO.StreamWriter(file);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ Console.SetOut(writer);
+
+ using (var dbcontext = new MovieCodedBasedConfigDBContext())
+ {
+ dbcontext.Database.Log = new MySqlLogger(s => Console.Write(s)).Write;
+
+ dbcontext.Database.Initialize(true);
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+ dbcontext.SaveChanges();
+ }
+ Console.SetOut(txtOut);
+ writer.Close();
+ file.Close();
+
+ Assert.That(System.IO.File.Exists(logName), Is.EqualTo(true));
+ }
+
+ [Test]
+ public void EntityAndComplexTypeSupportTest()
+ {
+ using (var dbContext = new EntityAndComplexTypeContext())
+ {
+ dbContext.Database.Initialize(true);
+ dbContext.Students.Add(
+ new Student()
+ {
+ Name = "Pakorasu Pakolas",
+ Address = new Address() { City = "Mazatlan", Street = "Tierra de Venados 440" },
+ Schedule = new List() { new SchoolSchedule() { TeacherName = "Pako", Subject = SchoolSubject.History } }
+ });
+ dbContext.SaveChanges();
+
+ var student = (from s in dbContext.Students
+ select s).FirstOrDefault();
+
+ Assert.That(student, Is.Not.Null);
+ Assert.That(student.Schedule, Is.Not.Null);
+ Assert.That(student.Address.Street, Is.Not.Null);
+ Assert.That(student.Address.Street, Is.Not.Empty);
+ Assert.That(student.Schedule.Count(), Is.Not.EqualTo(0));
+ }
+ }
+
+ ///
+ /// TO RUN THIS TEST ITS NECESSARY TO ENABLE THE EXECUTION STRATEGY IN THE CLASS MySqlEFConfiguration (Source\MySql.Data.Entity\MySqlConfiguration.cs) AS WELL AS START A MYSQL SERVER INSTACE WITH THE OPTION "--max_connections=3"
+ /// WHY 3?: 1)For main process (User: root, DB: mysql). 2)For Setup Class. 3)For the connections in this test.
+ /// The expected result is that opening a third connection and trying to open a fourth(with an asynchronous task) the execution strategy implementation handle the reconnection process until the third one is closed.
+ ///
+ //[Test] //<---DON'T FORGET ME TO RUN! =D
+ public void ExecutionStrategyTest()
+ {
+ var connection = new MySqlConnection("server=localhost;User Id=root;logging=true; port=" + Port + ";");
+ using (var dbcontext = new MovieCodedBasedConfigDBContext())
+ {
+ dbcontext.Database.Initialize(true);
+ dbcontext.Movies.Add(new MovieCBC()
+ {
+ Title = "Sharknado",
+ Genre = "Documental",
+ Price = 1.50M,
+ ReleaseDate = DateTime.Parse("01/07/2013")
+ });
+ connection.Open();
+ System.Threading.Tasks.Task.Factory.StartNew(() => { dbcontext.SaveChanges(); });
+ Thread.Sleep(1000);
+ connection.Close();
+ connection.Dispose();
+ }
+ var result = MySqlHelper.ExecuteScalar("server=localhost;User Id=root;database=test;logging=true; port=" + Port + ";", "select COUNT(*) from moviecbcs;");
+ Assert.That(int.Parse(result.ToString()), Is.EqualTo(1));
+ }
+
+ [Test]
+ public void UnknownProjectC1()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ long myKey = 20;
+ var q = (from r in db.Movies where (r.ID == myKey) select (long)r.ID).OrderBy(p => p);
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.UnknownProjectC1EF6);
+
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ long[] array = (from r in db.Movies where (r.ID == myKey) select (long)r.ID).OrderBy(p => p).ToArray();
+ }
+ }
+
+ [Test]
+ public void StartsWithTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ string term = "The";
+ var l = db.Movies.Where(p => p.Title.StartsWith(term));
+
+ string sql = l.ToString();
+
+ CheckSql(sql, SQLSyntax.QueryWithStartsWith);
+
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = l.Count();
+ foreach (var i in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void EndsWithTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ string term = "The";
+ var l = db.Movies.Where(p => p.Title.EndsWith(term));
+
+ string sql = l.ToString();
+
+ CheckSql(sql, SQLSyntax.QueryWithEndsWith);
+
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = l.Count();
+ foreach (var i in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void ContainsTest()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ MovieDBContext db = new MovieDBContext();
+ db.Database.Initialize(true);
+ MovieDBInitialize.DoDataPopulation(db);
+ string term = "The";
+ var l = db.Movies.Where(p => p.Title.Contains(term));
+
+ string sql = l.ToString();
+ CheckSql(sql, SQLSyntax.QueryWithContains);
+
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ int j = l.Count();
+ foreach (var i in l)
+ {
+ j--;
+ }
+ Assert.That(j, Is.EqualTo(0));
+ }
+
+
+ ///
+ /// Test to reproduce bug http://bugs.mysql.com/bug.php?id=73643, Exception when using IEnumera.Contains(model.property) in Where predicate
+ ///
+ [Test]
+ public void TestContainsListWithCast()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+
+ long[] longs = new long[] { 1, 2, 3 };
+ var q = db.Movies.Where(p => longs.Contains((long)p.ID));
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.TestContainsListWithCast);
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ var l = q.ToList();
+ }
+ }
+
+ ///
+ /// Test to reproduce bug http://bugs.mysql.com/bug.php?id=73643, Exception when using IEnumera.Contains(model.property) in Where predicate
+ ///
+ [Test]
+ public void TestContainsListWitConstant()
+ {
+#if DEBUG
+ Debug.WriteLine(new StackTrace().GetFrame(0).GetMethod().Name);
+#endif
+ using (MovieDBContext db = new MovieDBContext())
+ {
+ db.Database.Initialize(true);
+
+ List strIds = new List(new string[] { "two" });
+ var q = db.Movies.Where(p => strIds.Contains("two"));
+ string sql = q.ToString();
+ CheckSql(sql, SQLSyntax.TestContainsListWitConstant);
+#if DEBUG
+ Debug.WriteLine(sql);
+#endif
+ var l = q.ToList();
+ }
+ }
+
+ ///