From 0c61557e36955479e45fc5402568fd31e777a762 Mon Sep 17 00:00:00 2001 From: "David G. Moore, Jr" Date: Sat, 11 Nov 2023 20:41:08 -0500 Subject: [PATCH] Adding CustomSqlMigrationsGenerator --- src/All/Dgmjr.EntityFrameworkCore.csproj | 12 ++ src/All/Dgmjr.EntityFrameworkCore.sln | 112 ++++++++++++++++++ src/All/LICENSE.md | 35 ++++++ src/All/README.md | 27 +++++ src/Constants/All/LICENSE.md | 35 ++++++ src/Constants/Constants/Constants.cs | 5 + .../Dgmjr.EntityFrameworkCore.Constants.props | 1 + src/Constants/Constants/LICENSE.md | 35 ++++++ .../DbTypesNamesAndSchemas/LICENSE.md | 35 ++++++ .../CustomSqlMigrationsGenerator.cs | 49 ++++++++ ...gmjr.EntityFrameworkCore.Migrations.csproj | 4 + .../Dgmjr.EntityFrameworkCore.Migrations.sln | 52 ++++---- ...stomSqlMigrationsSqlGeneratorExtensions.cs | 10 ++ 13 files changed, 386 insertions(+), 26 deletions(-) create mode 100644 src/All/Dgmjr.EntityFrameworkCore.csproj create mode 100644 src/All/Dgmjr.EntityFrameworkCore.sln create mode 100755 src/All/LICENSE.md create mode 100644 src/All/README.md create mode 100755 src/Constants/All/LICENSE.md create mode 100755 src/Constants/Constants/LICENSE.md create mode 100755 src/Constants/DbTypesNamesAndSchemas/LICENSE.md create mode 100644 src/Migrations/CustomSqlMigrationsGenerator.cs create mode 100644 src/Migrations/UseCustomSqlMigrationsSqlGeneratorExtensions.cs diff --git a/src/All/Dgmjr.EntityFrameworkCore.csproj b/src/All/Dgmjr.EntityFrameworkCore.csproj new file mode 100644 index 0000000..c1e158a --- /dev/null +++ b/src/All/Dgmjr.EntityFrameworkCore.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0;netstandard2.1;net6.0;net8.0 + + + + + + + + + diff --git a/src/All/Dgmjr.EntityFrameworkCore.sln b/src/All/Dgmjr.EntityFrameworkCore.sln new file mode 100644 index 0000000..61da010 --- /dev/null +++ b/src/All/Dgmjr.EntityFrameworkCore.sln @@ -0,0 +1,112 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B283EBC2-E01F-412D-9339-FD56EF114549}" + ProjectSection(SolutionItems) = preProject + ..\..\..\..\Directory.Build.props = ..\..\..\..\Directory.Build.props + ..\..\..\..\Directory.Build.targets = ..\..\..\..\Directory.Build.targets + ..\..\..\..\global.json = ..\..\..\..\global.json + ..\..\..\..\Packages\Versions.Local.props = ..\..\..\..\Packages\Versions.Local.props + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Abstractions", "..\Abstractions\Dgmjr.EntityFrameworkCore.Abstractions.csproj", "{E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Constants.All", "..\Constants\All\Dgmjr.EntityFrameworkCore.Constants.All.csproj", "{5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Extensions", "..\Extensions\Dgmjr.EntityFrameworkCore.Extensions.csproj", "{963A870B-D69A-4EEC-B7DD-3FCF6B725F24}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Migrations", "..\Migrations\Dgmjr.EntityFrameworkCore.Migrations.csproj", "{EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Models", "..\Models\Dgmjr.EntityFrameworkCore.Models.csproj", "{BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore", "Dgmjr.EntityFrameworkCore.csproj", "{131AE4BC-9720-4D7A-B618-4EB1CE9B563B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Local|Any CPU = Local|Any CPU + Debug|Any CPU = Debug|Any CPU + Testing|Any CPU = Testing|Any CPU + Staging|Any CPU = Staging|Any CPU + Production|Any CPU = Production|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Local|Any CPU.ActiveCfg = Local|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Local|Any CPU.Build.0 = Local|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Testing|Any CPU.Build.0 = Testing|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Staging|Any CPU.Build.0 = Staging|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Production|Any CPU.ActiveCfg = Local|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Production|Any CPU.Build.0 = Local|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E83297C6-8CC6-4A55-ADD2-AA2CEEE6A809}.Release|Any CPU.Build.0 = Release|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Local|Any CPU.ActiveCfg = Local|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Local|Any CPU.Build.0 = Local|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Testing|Any CPU.Build.0 = Testing|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Staging|Any CPU.Build.0 = Staging|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Production|Any CPU.ActiveCfg = Local|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Production|Any CPU.Build.0 = Local|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BAF1F3E-B3FC-47CE-9B6D-52C670E986F5}.Release|Any CPU.Build.0 = Release|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Local|Any CPU.ActiveCfg = Local|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Local|Any CPU.Build.0 = Local|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Testing|Any CPU.Build.0 = Testing|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Staging|Any CPU.Build.0 = Staging|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Production|Any CPU.ActiveCfg = Local|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Production|Any CPU.Build.0 = Local|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {963A870B-D69A-4EEC-B7DD-3FCF6B725F24}.Release|Any CPU.Build.0 = Release|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Local|Any CPU.ActiveCfg = Local|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Local|Any CPU.Build.0 = Local|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Testing|Any CPU.Build.0 = Testing|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Staging|Any CPU.Build.0 = Staging|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Production|Any CPU.ActiveCfg = Local|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Production|Any CPU.Build.0 = Local|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EFDCABC6-A450-4EFA-A31F-5F7DBF7B5761}.Release|Any CPU.Build.0 = Release|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Local|Any CPU.ActiveCfg = Local|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Local|Any CPU.Build.0 = Local|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Testing|Any CPU.Build.0 = Testing|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Staging|Any CPU.Build.0 = Staging|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Production|Any CPU.ActiveCfg = Local|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Production|Any CPU.Build.0 = Local|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD67EBB3-FA03-44A5-8FB7-2B0C0BD24CFE}.Release|Any CPU.Build.0 = Release|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Local|Any CPU.ActiveCfg = Local|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Local|Any CPU.Build.0 = Local|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Testing|Any CPU.Build.0 = Testing|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Staging|Any CPU.Build.0 = Staging|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Production|Any CPU.ActiveCfg = Local|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Production|Any CPU.Build.0 = Local|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {131AE4BC-9720-4D7A-B618-4EB1CE9B563B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {260FE498-3701-4608-8F83-51A3DF241342} + EndGlobalSection +EndGlobal diff --git a/src/All/LICENSE.md b/src/All/LICENSE.md new file mode 100755 index 0000000..2b5eaac --- /dev/null +++ b/src/All/LICENSE.md @@ -0,0 +1,35 @@ +--- +date: 2023-07-13T05:44:46.048Z +description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... +keywords: + - IP + - copyright + - license + - mit +permissions: + - commercial-use + - modifications + - distribution + - private-use +conditions: + - include-copyright +liimitations: + - liability + - warranty +lastmod: 2023-08-29T17:13:51.216Z +license: MIT +slug: mit-license +title: MIT License +type: license +--- + +# MIT License + +## Copyright © 2022-2023 [David G. Moore, Jr.](mailto:david@dgmjr.io "Send David an email") ([@dgmjr](https://github.com/dgmjr "Contact david on GitHub")), All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/All/README.md b/src/All/README.md new file mode 100644 index 0000000..fe78523 --- /dev/null +++ b/src/All/README.md @@ -0,0 +1,27 @@ +--- +title: +lastmod: 2023-57-08T06:57:56.6492-05:00Z +date: 2023-57-08T06:57:56.6493-05:00Z +license: MIT +slug: Dgmjr.EntityFrameworkCore-readme +version: +authors: + - dgmjr; +description: Dgmjr.EntityFrameworkCore Readme #TODO: write description for Dgmjr.EntityFrameworkCore Readme +keywords: +- Dgmjr.EntityFrameworkCore + - dgmjr + - dgmjr-io +type: readme +--- +# Dgmjr.EntityFrameworkCore Readme + +## Package Description +## Getting Started +## Prerequisites +## Installation +## Usage +## Contributing +## Versioning +Built from [commit 8be612d on branch main at ] +(/tree/8be612dc6a4caab93296107541ceaebeabf742a4) diff --git a/src/Constants/All/LICENSE.md b/src/Constants/All/LICENSE.md new file mode 100755 index 0000000..2b5eaac --- /dev/null +++ b/src/Constants/All/LICENSE.md @@ -0,0 +1,35 @@ +--- +date: 2023-07-13T05:44:46.048Z +description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... +keywords: + - IP + - copyright + - license + - mit +permissions: + - commercial-use + - modifications + - distribution + - private-use +conditions: + - include-copyright +liimitations: + - liability + - warranty +lastmod: 2023-08-29T17:13:51.216Z +license: MIT +slug: mit-license +title: MIT License +type: license +--- + +# MIT License + +## Copyright © 2022-2023 [David G. Moore, Jr.](mailto:david@dgmjr.io "Send David an email") ([@dgmjr](https://github.com/dgmjr "Contact david on GitHub")), All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/Constants/Constants/Constants.cs b/src/Constants/Constants/Constants.cs index 045d450..d4b14b7 100644 --- a/src/Constants/Constants/Constants.cs +++ b/src/Constants/Constants/Constants.cs @@ -18,6 +18,11 @@ public static class Prefixes public const string ch_ = nameof(ch_); } +public static class Suffixes +{ + public const string _sql = ".sql"; +} + public static class UriMaxLengthConstant { public const int UriMaxLength = 2048; diff --git a/src/Constants/Constants/Dgmjr.EntityFrameworkCore.Constants.props b/src/Constants/Constants/Dgmjr.EntityFrameworkCore.Constants.props index 1c55873..c8fad64 100644 --- a/src/Constants/Constants/Dgmjr.EntityFrameworkCore.Constants.props +++ b/src/Constants/Constants/Dgmjr.EntityFrameworkCore.Constants.props @@ -15,6 +15,7 @@ + diff --git a/src/Constants/Constants/LICENSE.md b/src/Constants/Constants/LICENSE.md new file mode 100755 index 0000000..2b5eaac --- /dev/null +++ b/src/Constants/Constants/LICENSE.md @@ -0,0 +1,35 @@ +--- +date: 2023-07-13T05:44:46.048Z +description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... +keywords: + - IP + - copyright + - license + - mit +permissions: + - commercial-use + - modifications + - distribution + - private-use +conditions: + - include-copyright +liimitations: + - liability + - warranty +lastmod: 2023-08-29T17:13:51.216Z +license: MIT +slug: mit-license +title: MIT License +type: license +--- + +# MIT License + +## Copyright © 2022-2023 [David G. Moore, Jr.](mailto:david@dgmjr.io "Send David an email") ([@dgmjr](https://github.com/dgmjr "Contact david on GitHub")), All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/Constants/DbTypesNamesAndSchemas/LICENSE.md b/src/Constants/DbTypesNamesAndSchemas/LICENSE.md new file mode 100755 index 0000000..2b5eaac --- /dev/null +++ b/src/Constants/DbTypesNamesAndSchemas/LICENSE.md @@ -0,0 +1,35 @@ +--- +date: 2023-07-13T05:44:46.048Z +description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... +keywords: + - IP + - copyright + - license + - mit +permissions: + - commercial-use + - modifications + - distribution + - private-use +conditions: + - include-copyright +liimitations: + - liability + - warranty +lastmod: 2023-08-29T17:13:51.216Z +license: MIT +slug: mit-license +title: MIT License +type: license +--- + +# MIT License + +## Copyright © 2022-2023 [David G. Moore, Jr.](mailto:david@dgmjr.io "Send David an email") ([@dgmjr](https://github.com/dgmjr "Contact david on GitHub")), All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/Migrations/CustomSqlMigrationsGenerator.cs b/src/Migrations/CustomSqlMigrationsGenerator.cs new file mode 100644 index 0000000..e78d76e --- /dev/null +++ b/src/Migrations/CustomSqlMigrationsGenerator.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations.Operations; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Update; +using Microsoft.EntityFrameworkCore.Metadata; + +namespace Dgmjr.EntityFrameworkCore.Migrations; + +#if !NETSTANDARD2_1_OR_GREATER +public class CustomSqlMigrationsGenerator( + MigrationsSqlGeneratorDependencies dependencies, + IMigrationsAnnotationProvider migrationsAnnotations +) : SqlServerMigrationsSqlGenerator(dependencies, migrationsAnnotations) +#elif NETSTANDARD2_1_OR_GREATER && !NET8_0_OR_GREATER +public class CustomSqlMigrationsGenerator( + MigrationsSqlGeneratorDependencies dependencies, + IRelationalAnnotationProvider annotationsProvider +) : SqlServerMigrationsSqlGenerator(dependencies, annotationsProvider) +#elif NET8_0_OR_GREATER +public class CustomSqlMigrationsGenerator( + MigrationsSqlGeneratorDependencies dependencies, + ICommandBatchPreparer commandBatchPreparer +) : SqlServerMigrationsSqlGenerator(dependencies, commandBatchPreparer) +#else +#error "Unsupported target framework" +#endif +{ + protected ISqlGenerationHelper SqlHelper => Dependencies.SqlGenerationHelper; + + protected override void Generate( + MigrationOperation operation, + IModel model, + MigrationCommandListBuilder builder + ) + { + if (operation is CreateFunctionOperation cfo) + { + builder.Append(cfo.Sql).Append(SqlHelper.StatementTerminator).EndCommand(); + } + else if (operation is DropFunctionOperation dfo) + { + builder.Append(dfo.Sql).Append(SqlHelper.StatementTerminator).EndCommand(); + } + else + { + base.Generate(operation, model, builder); + } + } +} diff --git a/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.csproj b/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.csproj index c58c24e..fde521a 100644 --- a/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.csproj +++ b/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.csproj @@ -4,9 +4,13 @@ + + + + diff --git a/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.sln b/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.sln index 4f76393..77671fd 100644 --- a/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.sln +++ b/src/Migrations/Dgmjr.EntityFrameworkCore.Migrations.sln @@ -8,9 +8,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\..\..\Packages\Versions.Local.props = ..\..\..\..\Packages\Versions.Local.props EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Constants.DbTypesNamesAndSchemas", "..\Constants\DbTypesNamesAndSchemas\Dgmjr.EntityFrameworkCore.Constants.DbTypesNamesAndSchemas.csproj", "{06535008-E6CA-4052-B33B-727386835884}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Constants.DbTypesNamesAndSchemas", "..\Constants\DbTypesNamesAndSchemas\Dgmjr.EntityFrameworkCore.Constants.DbTypesNamesAndSchemas.csproj", "{BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Migrations", "Dgmjr.EntityFrameworkCore.Migrations.csproj", "{CBEC6380-04EC-404C-9CEB-D304E7C449D4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dgmjr.EntityFrameworkCore.Migrations", "Dgmjr.EntityFrameworkCore.Migrations.csproj", "{82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -22,30 +22,30 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {06535008-E6CA-4052-B33B-727386835884}.Local|Any CPU.ActiveCfg = Local|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Local|Any CPU.Build.0 = Local|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Testing|Any CPU.ActiveCfg = Testing|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Testing|Any CPU.Build.0 = Testing|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Staging|Any CPU.ActiveCfg = Staging|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Staging|Any CPU.Build.0 = Staging|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Production|Any CPU.ActiveCfg = Local|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Production|Any CPU.Build.0 = Local|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06535008-E6CA-4052-B33B-727386835884}.Release|Any CPU.Build.0 = Release|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Local|Any CPU.ActiveCfg = Local|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Local|Any CPU.Build.0 = Local|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Testing|Any CPU.ActiveCfg = Testing|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Testing|Any CPU.Build.0 = Testing|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Staging|Any CPU.ActiveCfg = Staging|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Staging|Any CPU.Build.0 = Staging|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Production|Any CPU.ActiveCfg = Local|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Production|Any CPU.Build.0 = Local|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CBEC6380-04EC-404C-9CEB-D304E7C449D4}.Release|Any CPU.Build.0 = Release|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Local|Any CPU.ActiveCfg = Local|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Local|Any CPU.Build.0 = Local|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Testing|Any CPU.Build.0 = Testing|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Staging|Any CPU.Build.0 = Staging|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Production|Any CPU.ActiveCfg = Local|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Production|Any CPU.Build.0 = Local|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF2CC7F2-A148-4B18-B8EB-2E3786B645A7}.Release|Any CPU.Build.0 = Release|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Local|Any CPU.ActiveCfg = Local|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Local|Any CPU.Build.0 = Local|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Testing|Any CPU.ActiveCfg = Testing|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Testing|Any CPU.Build.0 = Testing|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Staging|Any CPU.ActiveCfg = Staging|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Staging|Any CPU.Build.0 = Staging|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Production|Any CPU.ActiveCfg = Local|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Production|Any CPU.Build.0 = Local|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82DD3EA1-5238-4AB2-8DD3-2C2E5CC2B26F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Migrations/UseCustomSqlMigrationsSqlGeneratorExtensions.cs b/src/Migrations/UseCustomSqlMigrationsSqlGeneratorExtensions.cs new file mode 100644 index 0000000..9781eee --- /dev/null +++ b/src/Migrations/UseCustomSqlMigrationsSqlGeneratorExtensions.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Dgmjr.EntityFrameworkCore.Migrations; + +public static class UseCustomSqlMigrationsSqlGeneratorExtensions +{ + public static DbContextOptionsBuilder UseCustomSqlMigrationsSqlGenerator( + this DbContextOptionsBuilder optionsBuilder + ) => optionsBuilder.ReplaceService(); +}