diff --git a/.editorconfig b/.editorconfig index 71b54e407..773cf0ab3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,29 @@ indent_style = space indent_size = 4 ; trim_trailing_whitespace = true insert_final_newline = true + +[*.cs] +dotnet_style_qualification_for_field = false:error +dotnet_style_qualification_for_property = false:error +dotnet_style_qualification_for_method = false:error +dotnet_style_qualification_for_event = false:error +dotnet_style_predefined_type_for_locals_parameters_members = true:error +dotnet_style_predefined_type_for_member_access = true:error +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +csharp_style_var_for_built_in_types = true:error +csharp_style_var_when_type_is_apparent = true:error +csharp_style_var_elsewhere = true:suggestion +csharp_style_expression_bodied_methods = true:suggestion +csharp_style_expression_bodied_constructors = true:suggestion +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion diff --git a/Npgsql.EntityFrameworkCore.PostgreSQL-xproj.sln b/Npgsql.EntityFrameworkCore.PostgreSQL-xproj.sln deleted file mode 100644 index eb8d71ddb..000000000 --- a/Npgsql.EntityFrameworkCore.PostgreSQL-xproj.sln +++ /dev/null @@ -1,114 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4A5A60DD-41B6-40BF-B677-227A921ECCC8}" - ProjectSection(SolutionItems) = preProject - CommonAssemblyInfo.cs = CommonAssemblyInfo.cs - Npgsql.snk = Npgsql.snk - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{ED612DB1-AB32-4603-95E7-891BACA71C39}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Npgsql.EntityFrameworkCore.PostgreSQL", "src\Npgsql.EntityFrameworkCore.PostgreSQL\Npgsql.EntityFrameworkCore.PostgreSQL.xproj", "{A6370FDF-2140-4780-9671-FFCE9688A1AB}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore", "..\EntityFramework\src\Microsoft.EntityFrameworkCore\Microsoft.EntityFrameworkCore.xproj", "{45C6A6D2-AD42-4CFE-BF5C-A56ECB8563BD}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Relational", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Microsoft.EntityFrameworkCore.Relational.xproj", "{539436BC-9F4B-4492-8ECC-4451E0C3FDEC}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Npgsql.EntityFrameworkCore.PostgreSQL.Design", "src\Npgsql.EntityFrameworkCore.PostgreSQL.Design\Npgsql.EntityFrameworkCore.PostgreSQL.Design.xproj", "{180FC3CA-E92E-4B89-8A3A-81302F088F2E}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Design.Core", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Design.Core\Microsoft.EntityFrameworkCore.Design.Core.xproj", "{6C155372-A8A1-4E3B-8808-E875AFE452C8}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Relational.Design", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational.Design\Microsoft.EntityFrameworkCore.Relational.Design.xproj", "{0B4B5871-2017-40CA-B190-AEDB974D843D}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Npgsql.EntityFrameworkCore.PostgreSQL.Tests", "test\Npgsql.EntityFrameworkCore.PostgreSQL.Tests\Npgsql.EntityFrameworkCore.PostgreSQL.Tests.xproj", "{6584213E-212A-4262-810D-E121A7E737F1}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.InMemory", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.InMemory\Microsoft.EntityFrameworkCore.InMemory.xproj", "{B082A621-EF4B-415B-B8C2-BE4EEE791B52}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Relational.Specification.Tests", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational.Specification.Tests\Microsoft.EntityFrameworkCore.Relational.Specification.Tests.xproj", "{E2703F17-D2F9-43F7-A379-D0A8833AEE1E}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Specification.Tests", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Specification.Tests\Microsoft.EntityFrameworkCore.Specification.Tests.xproj", "{AAB3C3CD-0BDD-494B-83AD-F3295AAA13CF}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests", "test\Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests\Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.xproj", "{2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests", "test\Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests\Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.xproj", "{67553B48-F896-4D76-9210-95AAE6707F60}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests", "..\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests\Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests.xproj", "{88796EE8-B48B-434D-AC55-FAFFC9BE0D77}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A6370FDF-2140-4780-9671-FFCE9688A1AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6370FDF-2140-4780-9671-FFCE9688A1AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6370FDF-2140-4780-9671-FFCE9688A1AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6370FDF-2140-4780-9671-FFCE9688A1AB}.Release|Any CPU.Build.0 = Release|Any CPU - {45C6A6D2-AD42-4CFE-BF5C-A56ECB8563BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45C6A6D2-AD42-4CFE-BF5C-A56ECB8563BD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45C6A6D2-AD42-4CFE-BF5C-A56ECB8563BD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45C6A6D2-AD42-4CFE-BF5C-A56ECB8563BD}.Release|Any CPU.Build.0 = Release|Any CPU - {539436BC-9F4B-4492-8ECC-4451E0C3FDEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {539436BC-9F4B-4492-8ECC-4451E0C3FDEC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {539436BC-9F4B-4492-8ECC-4451E0C3FDEC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {539436BC-9F4B-4492-8ECC-4451E0C3FDEC}.Release|Any CPU.Build.0 = Release|Any CPU - {180FC3CA-E92E-4B89-8A3A-81302F088F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {180FC3CA-E92E-4B89-8A3A-81302F088F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {180FC3CA-E92E-4B89-8A3A-81302F088F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {180FC3CA-E92E-4B89-8A3A-81302F088F2E}.Release|Any CPU.Build.0 = Release|Any CPU - {6C155372-A8A1-4E3B-8808-E875AFE452C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C155372-A8A1-4E3B-8808-E875AFE452C8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C155372-A8A1-4E3B-8808-E875AFE452C8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C155372-A8A1-4E3B-8808-E875AFE452C8}.Release|Any CPU.Build.0 = Release|Any CPU - {0B4B5871-2017-40CA-B190-AEDB974D843D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0B4B5871-2017-40CA-B190-AEDB974D843D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0B4B5871-2017-40CA-B190-AEDB974D843D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0B4B5871-2017-40CA-B190-AEDB974D843D}.Release|Any CPU.Build.0 = Release|Any CPU - {6584213E-212A-4262-810D-E121A7E737F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6584213E-212A-4262-810D-E121A7E737F1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6584213E-212A-4262-810D-E121A7E737F1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6584213E-212A-4262-810D-E121A7E737F1}.Release|Any CPU.Build.0 = Release|Any CPU - {B082A621-EF4B-415B-B8C2-BE4EEE791B52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B082A621-EF4B-415B-B8C2-BE4EEE791B52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B082A621-EF4B-415B-B8C2-BE4EEE791B52}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B082A621-EF4B-415B-B8C2-BE4EEE791B52}.Release|Any CPU.Build.0 = Release|Any CPU - {E2703F17-D2F9-43F7-A379-D0A8833AEE1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2703F17-D2F9-43F7-A379-D0A8833AEE1E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2703F17-D2F9-43F7-A379-D0A8833AEE1E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2703F17-D2F9-43F7-A379-D0A8833AEE1E}.Release|Any CPU.Build.0 = Release|Any CPU - {AAB3C3CD-0BDD-494B-83AD-F3295AAA13CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAB3C3CD-0BDD-494B-83AD-F3295AAA13CF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAB3C3CD-0BDD-494B-83AD-F3295AAA13CF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAB3C3CD-0BDD-494B-83AD-F3295AAA13CF}.Release|Any CPU.Build.0 = Release|Any CPU - {2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE}.Release|Any CPU.Build.0 = Release|Any CPU - {67553B48-F896-4D76-9210-95AAE6707F60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {67553B48-F896-4D76-9210-95AAE6707F60}.Debug|Any CPU.Build.0 = Debug|Any CPU - {67553B48-F896-4D76-9210-95AAE6707F60}.Release|Any CPU.ActiveCfg = Release|Any CPU - {67553B48-F896-4D76-9210-95AAE6707F60}.Release|Any CPU.Build.0 = Release|Any CPU - {88796EE8-B48B-434D-AC55-FAFFC9BE0D77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88796EE8-B48B-434D-AC55-FAFFC9BE0D77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88796EE8-B48B-434D-AC55-FAFFC9BE0D77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88796EE8-B48B-434D-AC55-FAFFC9BE0D77}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {A6370FDF-2140-4780-9671-FFCE9688A1AB} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050} - {180FC3CA-E92E-4B89-8A3A-81302F088F2E} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050} - {6584213E-212A-4262-810D-E121A7E737F1} = {ED612DB1-AB32-4603-95E7-891BACA71C39} - {2FF9C05F-BBF1-4AE0-AB73-017751DEF4DE} = {ED612DB1-AB32-4603-95E7-891BACA71C39} - {67553B48-F896-4D76-9210-95AAE6707F60} = {ED612DB1-AB32-4603-95E7-891BACA71C39} - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Npgsql.csproj - EndGlobalSection -EndGlobal diff --git a/Npgsql.EntityFrameworkCore.PostgreSQL.sln b/Npgsql.EntityFrameworkCore.PostgreSQL.sln index a75426235..49f030e7e 100644 --- a/Npgsql.EntityFrameworkCore.PostgreSQL.sln +++ b/Npgsql.EntityFrameworkCore.PostgreSQL.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26206.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4A5A60DD-41B6-40BF-B677-227A921ECCC8}" ProjectSection(SolutionItems) = preProject @@ -26,29 +25,53 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Debug|x64.ActiveCfg = Debug|Any CPU + {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Debug|x86.ActiveCfg = Debug|Any CPU {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Release|Any CPU.Build.0 = Release|Any CPU + {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Release|x64.ActiveCfg = Release|Any CPU + {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A}.Release|x86.ActiveCfg = Release|Any CPU {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Debug|x64.ActiveCfg = Debug|Any CPU + {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Debug|x86.ActiveCfg = Debug|Any CPU {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Release|Any CPU.Build.0 = Release|Any CPU + {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Release|x64.ActiveCfg = Release|Any CPU + {8EDCED17-2D1D-45BE-9B61-0F715876DA94}.Release|x86.ActiveCfg = Release|Any CPU {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Debug|x64.ActiveCfg = Debug|Any CPU + {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Debug|x86.ActiveCfg = Debug|Any CPU {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Release|Any CPU.ActiveCfg = Release|Any CPU {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Release|Any CPU.Build.0 = Release|Any CPU + {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Release|x64.ActiveCfg = Release|Any CPU + {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01}.Release|x86.ActiveCfg = Release|Any CPU {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Debug|x86.ActiveCfg = Debug|Any CPU {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Release|Any CPU.Build.0 = Release|Any CPU + {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Release|x64.ActiveCfg = Release|Any CPU + {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D}.Release|x86.ActiveCfg = Release|Any CPU {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Debug|x64.ActiveCfg = Debug|Any CPU + {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Debug|x86.ActiveCfg = Debug|Any CPU {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|Any CPU.Build.0 = Release|Any CPU + {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|x64.ActiveCfg = Release|Any CPU + {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/bump.sh b/bump.sh old mode 100644 new mode 100755 diff --git a/global.json b/global.json deleted file mode 100644 index e53c0eeff..000000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "projects": [ "src", "test" ], - "sdk": { - "version": "1.0.0-preview2-003131" - } -} diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDatabaseModelFactory.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDatabaseModelFactory.cs index dcde0e982..aecc924a1 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDatabaseModelFactory.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDatabaseModelFactory.cs @@ -104,6 +104,13 @@ public DatabaseModel Create(DbConnection connection, TableSelectionSet tableSele GetIndexes(); GetConstraints(); GetSequences(); + + // We may have dropped columns. We load these because constraints take them into + // account when referencing columns, but must now get rid of them before returning + // the database model. + foreach (var table in _databaseModel.Tables) + while (table.Columns.Remove(null)) {} + return _databaseModel; } finally @@ -148,7 +155,7 @@ void GetTables() const string GetColumnsQuery = @" SELECT - nspname, relname, attname, typ.typname, attnum, atttypmod, + nspname, relname, attisdropped, attname, typ.typname, attnum, atttypmod, CASE WHEN pg_proc.proname='array_recv' THEN 'a' ELSE typ.typtype END AS typtype, CASE WHEN pg_proc.proname='array_recv' THEN elemtyp.typname @@ -163,7 +170,6 @@ FROM pg_class AS cls LEFT OUTER JOIN pg_proc ON pg_proc.oid = typ.typreceive LEFT OUTER JOIN pg_type AS elemtyp ON (elemtyp.oid = typ.typelem) WHERE - atttypid <> 0 AND relkind = 'r' AND nspname NOT IN ('pg_catalog', 'information_schema') AND relname <> '" + HistoryRepository.DefaultTableName + @"' AND @@ -180,21 +186,30 @@ void GetColumns() var schemaName = reader.GetString(0); var tableName = reader.GetString(1); if (!_tableSelectionSet.Allows(schemaName, tableName)) + continue; + + var table = _tables[TableKey(tableName, schemaName)]; + + // We need to know about dropped columns because constraints take them into + // account when referencing columns. We'll get rid of them before returning the model. + var isDropped = reader.GetBoolean(2); + if (isDropped) { + table.Columns.Add(null); continue; } - var columnName = reader.GetString(2); - var dataType = reader.GetString(3); - var ordinal = reader.GetInt32(4) - 1; - var typeModifier = reader.GetInt32(5); - var typeChar = reader.GetChar(6); - var elemDataType = reader.IsDBNull(7) ? null : reader.GetString(7); - var isNullable = reader.GetBoolean(8); + var columnName = reader.GetString(3); + var dataType = reader.GetString(4); + var ordinal = reader.GetInt32(5) - 1; + var typeModifier = reader.GetInt32(6); + var typeChar = reader.GetChar(7); + var elemDataType = reader.IsDBNull(8) ? null : reader.GetString(8); + var isNullable = reader.GetBoolean(9); int? maxLength = null; int? precision = null; int? scale = null; - var defaultValue = reader.IsDBNull(9) ? null : reader.GetString(9); + var defaultValue = reader.IsDBNull(10) ? null : reader.GetString(10); if (typeModifier != -1) { @@ -214,7 +229,6 @@ void GetColumns() } } - var table = _tables[TableKey(tableName, schemaName)]; var column = new ColumnModel { Table = table, diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDesignTimeServices.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDesignTimeServices.cs index cec782c1e..417cf9d12 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDesignTimeServices.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Internal/NpgsqlDesignTimeServices.cs @@ -22,6 +22,7 @@ #endregion using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.Internal; @@ -29,9 +30,9 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { - public class NpgsqlDesignTimeServices + public class NpgsqlDesignTimeServices : IDesignTimeServices { - public virtual IServiceCollection ConfigureDesignTimeServices([NotNull] IServiceCollection serviceCollection) + public virtual void ConfigureDesignTimeServices([NotNull] IServiceCollection serviceCollection) => serviceCollection .AddSingleton() .AddSingleton() diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.csproj b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.csproj index ea498a2d3..c25df8a2b 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.csproj +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.csproj @@ -1,85 +1,38 @@ - - - + + - Debug - AnyCPU - {8EDCED17-2D1D-45BE-9B61-0F715876DA94} - Library - Properties - Npgsql.EntityFrameworkCore.PostgreSQL.Design + 1.1.1 + net451;netstandard1.3 + true + ../../Npgsql.snk true - ..\..\Npgsql.snk - Npgsql.EntityFrameworkCore.PostgreSQL.Design - v4.5.1 - 512 + true + PostgreSQL/Npgsql provider for Entity Framework Core. + Shay Rojansky + Npgsql + npgsql;postgresql;postgres;Entity Framework Core;entity-framework-core;ef;efcore;orm;sql + Copyright 2017 © The Npgsql Development Team + http://www.npgsql.org/img/postgresql.gif + https://raw.githubusercontent.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/dev/LICENSE.txt + git + git://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - + - - Check.cs - - - - - - - - - - - - - Properties\CommonAssemblyInfo.cs - Code - - - + + - + + - - {fadda2d1-03b4-4def-8d24-dd1ca4e81f4a} - Npgsql.EntityFrameworkCore.PostgreSQL - + + + + + + - - + diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.project.json b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.project.json deleted file mode 100644 index 6681d2bf6..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "dependencies" : { - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Design": "1.1.0", - "Microsoft.Extensions.DependencyInjection": "1.1.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.xproj b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.xproj deleted file mode 100644 index 135e589db..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 180fc3ca-e92e-4b89-8a3a-81302f088f2e - Npgsql.EntityFrameworkCore.PostgreSQL.Design - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Properties/AssemblyInfo.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Properties/AssemblyInfo.cs index 7231e6cfa..f0b718cfd 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Properties/AssemblyInfo.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/Properties/AssemblyInfo.cs @@ -1,10 +1,2 @@ using System.Reflection; -// 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("Npgsql.EntityFrameworkCore.PostgreSQL.Design")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json b/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json deleted file mode 100644 index 35312daf7..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "1.1.0", - "packOptions": { - "authors": [ "Shay Rojansky" ], - "description": "Design-time Entity Framework Core Functionality for PostgreSQL", - "iconUrl": "http://www.npgsql.org/img/postgresql.gif", - "licenseUrl": "https://raw.githubusercontent.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/dev/LICENSE.txt", - "repository": { - "type": "git", - "url": "git://github.com/npgsql/npgsql" - } - }, - "buildOptions": { - "keyFile": "../../Npgsql.snk", - "warningsAsErrors": true, - "compile": { - "include": "../Shared/*.cs" - } - }, - "dependencies" : { - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Design": "1.1.0", - "Microsoft.Extensions.DependencyInjection": "1.1.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {}, - "netstandard13": { - "imports": [ - "portable-net452+win81" - ], - "dependencies": { - } - } - } -} diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/Internal/NpgsqlValueGenerationStrategyConvention.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/Internal/NpgsqlValueGenerationStrategyConvention.cs index 408716549..4d5a4e4df 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/Internal/NpgsqlValueGenerationStrategyConvention.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/Internal/NpgsqlValueGenerationStrategyConvention.cs @@ -7,23 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal { - /// - /// This API supports the Entity Framework Core infrastructure and is not intended to be used - /// directly from your code. This API may change or be removed in future releases. - /// - public class NpgsqlValueGenerationStrategyConvention : DatabaseGeneratedAttributeConvention, IModelConvention + public class NpgsqlValueGenerationStrategyConvention : IModelConvention { - public override InternalPropertyBuilder Apply( - InternalPropertyBuilder propertyBuilder, DatabaseGeneratedAttribute attribute, MemberInfo clrMember) - { - propertyBuilder.Npgsql(ConfigurationSource.DataAnnotation).ValueGenerationStrategy( - attribute.DatabaseGeneratedOption == DatabaseGeneratedOption.Identity - ? NpgsqlValueGenerationStrategy.SerialColumn - : (NpgsqlValueGenerationStrategy?)null); - - return base.Apply(propertyBuilder, attribute, clrMember); - } - /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/NpgsqlConventionSetBuilder.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/NpgsqlConventionSetBuilder.cs index d944cc9f0..345d850ad 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/NpgsqlConventionSetBuilder.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Metadata/Conventions/NpgsqlConventionSetBuilder.cs @@ -48,9 +48,6 @@ public override ConventionSet AddConventions(ConventionSet conventionSet) var valueGenerationStrategyConvention = new NpgsqlValueGenerationStrategyConvention(); conventionSet.ModelInitializedConventions.Add(valueGenerationStrategyConvention); - ReplaceConvention(conventionSet.PropertyAddedConventions, (DatabaseGeneratedAttributeConvention)valueGenerationStrategyConvention); - ReplaceConvention(conventionSet.PropertyFieldChangedConventions, (DatabaseGeneratedAttributeConvention)valueGenerationStrategyConvention); - return conventionSet; } } diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlHistoryRepository.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlHistoryRepository.cs index 75256d477..173142bdd 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlHistoryRepository.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlHistoryRepository.cs @@ -85,22 +85,25 @@ protected override string ExistsSql public override string GetCreateIfNotExistsScript() { - return GetCreateScript(); + var script = GetCreateScript(); + return script.Insert(script.IndexOf("CREATE TABLE", StringComparison.Ordinal) + 12, " IF NOT EXISTS"); } - public override string GetBeginIfNotExistsScript(string migrationId) - { - throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by Npgsql"); - } + public override string GetBeginIfNotExistsScript(string migrationId) => $@" +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM {SqlGenerationHelper.DelimitIdentifier(TableName, TableSchema)} WHERE ""{MigrationIdColumnName}"" = '{migrationId}') THEN"; - public override string GetBeginIfExistsScript(string migrationId) - { - throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by Npgsql"); - } + public override string GetBeginIfExistsScript(string migrationId) => $@" +DO $$ +BEGIN + IF EXISTS(SELECT 1 FROM {SqlGenerationHelper.DelimitIdentifier(TableName, TableSchema)} WHERE ""{MigrationIdColumnName}"" = '{migrationId}') THEN"; public override string GetEndIfScript() { - throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by Npgsql"); + return +@" END IF; +END $$;"; } } } diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlMigrationsAnnotationProvider.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlMigrationsAnnotationProvider.cs index c546f5e9e..a936367c8 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlMigrationsAnnotationProvider.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/Internal/NpgsqlMigrationsAnnotationProvider.cs @@ -32,6 +32,15 @@ namespace Microsoft.EntityFrameworkCore.Migrations.Internal { public class NpgsqlMigrationsAnnotationProvider : MigrationsAnnotationProvider { + public override IEnumerable For(IEntityType entityType) + { + foreach (var storageParamAnnotation in entityType.GetAnnotations() + .Where(a => a.Name.StartsWith(NpgsqlFullAnnotationNames.Instance.StorageParameterPrefix))) + { + yield return storageParamAnnotation; + } + } + public override IEnumerable For(IProperty property) { if (property.Npgsql().ValueGenerationStrategy == NpgsqlValueGenerationStrategy.SerialColumn) diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/NpgsqlMigrationsSqlGenerator.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/NpgsqlMigrationsSqlGenerator.cs index 2dee3b6f1..d46003a50 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/NpgsqlMigrationsSqlGenerator.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/NpgsqlMigrationsSqlGenerator.cs @@ -159,6 +159,19 @@ protected override void Generate(AlterTableOperation operation, IModel model, Mi base.Generate(operation, model, builder); } + protected override void Generate( + AddColumnOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate) + { + // Never touch system columns + if (IsSystemColumn(operation.Name)) + return; + + base.Generate(operation, model, builder, terminate); + } + protected override void Generate( DropColumnOperation operation, IModel model, @@ -235,12 +248,12 @@ protected override void Generate(AlterColumnOperation operation, IModel model, M else builder.Append("DROP DEFAULT"); + // Terminate the DEFAULT above + builder.AppendLine(SqlGenerationHelper.StatementTerminator); + // ALTER SEQUENCE if (sequenceName != null) { - // Terminate the DEFAULT above - builder.AppendLine(SqlGenerationHelper.StatementTerminator); - builder .Append("ALTER SEQUENCE ") .Append(SqlGenerationHelper.DelimitIdentifier(sequenceName)) diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.csproj b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.csproj index a357c2d03..b26b42d1c 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.csproj +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.csproj @@ -1,156 +1,33 @@ - - + + - Debug - AnyCPU - {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A} - Library - Properties - Npgsql.EntityFrameworkCore.PostgreSQL - Npgsql.EntityFrameworkCore.PostgreSQL - v4.5.1 - 512 + 1.1.1 + net451;netstandard1.3 + true + ../../Npgsql.snk true - ..\..\Npgsql.snk - + true + PostgreSQL/Npgsql provider for Entity Framework Core. + Shay Rojansky + Npgsql + npgsql;postgresql;postgres;Entity Framework Core;entity-framework-core;ef;efcore;orm;sql + Copyright 2017 © The Npgsql Development Team + http://www.npgsql.org/img/postgresql.gif + https://raw.githubusercontent.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/dev/LICENSE.txt + git + git://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Npgsql.EntityFrameworkCore.PostgreSQL.xml - 1591 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Npgsql.EntityFrameworkCore.PostgreSQL.xml - - - - - - - - - - - - - - + - - Check.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Properties\CommonAssemblyInfo.cs - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + - - - \ No newline at end of file + + diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.nuspec b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.nuspec deleted file mode 100644 index 0673e9799..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.nuspec +++ /dev/null @@ -1,28 +0,0 @@ - - - - EntityFramework7.Npgsql - Npgsql for Entity Framework 7 - 3.1.0-beta7-1 - Shay Rojansky - Shay Rojansky - https://github.com/npgsql/npgsql/blob/develop/LICENSE.txt - http://www.npgsql.org - Copyright 2002 - 2016 Npgsql Development Team - false - PostgreSQL provider for Entity Framework 7 - PostgreSQL provider for Entity Framework 7 - en-US - npgsql postgresql postgres data database entity framework ef orm - - - - - - - - - - - - diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.project.json b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.project.json deleted file mode 100644 index e4c8d8e24..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "dependencies" : { - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0", - "Microsoft.Extensions.DependencyInjection": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.xproj b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.xproj deleted file mode 100644 index 39d9ba718..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a6370fdf-2140-4780-9671-ffce9688a1ab - Npgsql.EntityFrameworkCore.PostgreSQL - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Properties/AssemblyInfo.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Properties/AssemblyInfo.cs index b7305d58c..3f6715dc4 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Properties/AssemblyInfo.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Properties/AssemblyInfo.cs @@ -5,9 +5,7 @@ using System.Resources; using Microsoft.EntityFrameworkCore.Infrastructure; -[assembly: AssemblyTitle("Npgsql.EntityFrameworkCore.PostgreSQL")] -[assembly: AssemblyDescription("PostgreSQL provider for Entity Framework Core")] [assembly: DesignTimeProviderServices( typeName: "Microsoft.EntityFrameworkCore.Scaffolding.Internal.NpgsqlDesignTimeServices", - assemblyName: "Npgsql.EntityFrameworkCore.PostgreSQL.Design, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7", + assemblyName: "Npgsql.EntityFrameworkCore.PostgreSQL.Design, Version=1.1.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7", packageName: "Npgsql.EntityFrameworkCore.PostgreSQL.Design")] diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlMathRoundTranslator.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlMathRoundTranslator.cs index 1bc4af629..8165ea63b 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlMathRoundTranslator.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlMathRoundTranslator.cs @@ -42,8 +42,8 @@ public virtual Expression Translate([NotNull] MethodCallExpression methodCallExp if (_methodInfos.Contains(methodCallExpression.Method)) { var arguments = methodCallExpression.Arguments.Count == 1 - ? new[] { methodCallExpression.Arguments[0], Expression.Constant(0) } - : new[] { methodCallExpression.Arguments[1], methodCallExpression.Arguments[1] }; + ? new[] { methodCallExpression.Arguments[0] } + : new[] { methodCallExpression.Arguments[0], methodCallExpression.Arguments[1] }; return new SqlFunctionExpression("ROUND", methodCallExpression.Type, arguments); } diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlStringReplaceTranslator.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlStringReplaceTranslator.cs index 3e40f7986..24f053c75 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlStringReplaceTranslator.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Query/ExpressionTranslators/Internal/NpgsqlStringReplaceTranslator.cs @@ -31,9 +31,8 @@ namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal { public class NpgsqlStringReplaceTranslator : IMethodCallTranslator { - private static readonly MethodInfo _methodInfo = typeof(string).GetTypeInfo().GetDeclaredMethods(nameof(string.Replace)) - .Where(m => m.GetParameters()[0].ParameterType == typeof(string)) - .Single(); + static readonly MethodInfo _methodInfo + = typeof(string).GetRuntimeMethod(nameof(string.Replace), new[] { typeof(string), typeof(string) }); public virtual Expression Translate([NotNull] MethodCallExpression methodCallExpression) { diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlDatabaseCreator.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlDatabaseCreator.cs index e1ed1b4ef..cef745c46 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlDatabaseCreator.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlDatabaseCreator.cs @@ -69,8 +69,18 @@ public override void Create() { using (var masterConnection = _connection.CreateMasterConnection()) { - MigrationCommandExecutor - .ExecuteNonQuery(CreateCreateOperations(), masterConnection); + try + { + MigrationCommandExecutor + .ExecuteNonQuery(CreateCreateOperations(), masterConnection); + } + catch (PostgresException e) when ( + e.SqlState == "23505" && e.TableName == "pg_database_datname_index" + ) + { + // This occurs when two connections are trying to create the same database concurrently + // (happens in the tests). Simply ignore the error. + } ClearPool(); } @@ -80,8 +90,18 @@ public override void Create() { using (var masterConnection = _connection.CreateMasterConnection()) { - await MigrationCommandExecutor - .ExecuteNonQueryAsync(CreateCreateOperations(), masterConnection, cancellationToken); + try + { + await MigrationCommandExecutor + .ExecuteNonQueryAsync(CreateCreateOperations(), masterConnection, cancellationToken); + } + catch (PostgresException e) when ( + e.SqlState == "23505" && e.TableName == "pg_database_datname_index" + ) + { + // This occurs when two connections are trying to create the same database concurrently + // (happens in the tests). Simply ignore the error. + } ClearPool(); } diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlTypeMapper.cs b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlTypeMapper.cs index c326d0b37..459562869 100644 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlTypeMapper.cs +++ b/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlTypeMapper.cs @@ -128,7 +128,10 @@ public override RelationalTypeMapping FindMapping(Type clrType) if (arrayElementType != null) { - var elementMapping = (NpgsqlBaseTypeMapping)FindMapping(arrayElementType); + // At least for now, we only support arrays of base (scalar) types. + // Notably, arrays of arrays aren't supported (as opposed to multidimensional arrays) because PostgreSQL + // doesn't support them. + var elementMapping = FindMapping(arrayElementType) as NpgsqlBaseTypeMapping; // If an element isn't supported, neither is its array if (elementMapping?.NpgsqlDbType == null) diff --git a/src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json b/src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json deleted file mode 100644 index c1aba357a..000000000 --- a/src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "version": "1.1.0", - "packOptions": { - "authors": [ "Shay Rojansky" ], - "description" : "PostgreSQL provider for Entity Framework Core", - "iconUrl": "http://www.npgsql.org/img/postgresql.gif", - "licenseUrl": "https://raw.githubusercontent.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/dev/LICENSE.txt", - "repository": { - "type": "git", - "url": "git://github.com/npgsql/npgsql" - } - }, - "buildOptions": { - "keyFile": "../../Npgsql.snk", - "warningsAsErrors": true, - "compile": { - "include": "../Shared/*.cs" - } - }, - "dependencies" : { - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0", - "Microsoft.Extensions.DependencyInjection": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {}, - "netstandard13": { - "imports": [ - "portable-net452+win81" - ], - "dependencies": { - } - } - } -} diff --git a/src/Shared/CommonAssemblyInfo.cs b/src/Shared/CommonAssemblyInfo.cs deleted file mode 100644 index 0c96d1810..000000000 --- a/src/Shared/CommonAssemblyInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using System.Security; -using System.Reflection; -using System.Resources; - -[assembly: AssemblyCompany("Npgsql Development Team")] -[assembly: AssemblyCopyright("Copyright © 2002 - 2016 Npgsql Development Team")] - -// The following version attributes get rewritten by GitVersion as part of the build -[assembly: AssemblyVersion("1.1.0")] -[assembly: AssemblyFileVersion("1.1.0")] -[assembly: AssemblyInformationalVersion("1.1.0")] diff --git a/teamcity_set_version.cmd b/teamcity_set_version.cmd index ef73d627b..cd2588990 100644 --- a/teamcity_set_version.cmd +++ b/teamcity_set_version.cmd @@ -1 +1 @@ -echo ##teamcity[buildNumber '1.1.0-%1'] +echo ##teamcity[buildNumber '1.1.1-ci-%1'] diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.csproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.csproj index 03e8836b5..2e34354a9 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.csproj +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.csproj @@ -1,191 +1,28 @@ - - - + + - Debug - AnyCPU - {1410D291-C519-4E74-AE3D-6BC6C4A7C1DC} - Library - Properties - Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests - Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests - v4.5.1 - 512 + net452;netcoreapp1.1 + true - - true - full - false - bin\Debug\ - NET451;DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - NET451;TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - + - - {8edced17-2d1d-45be-9b61-0f715876da94} - Npgsql.EntityFrameworkCore.PostgreSQL.Design - - - {fadda2d1-03b4-4def-8d24-dd1ca4e81f4a} - Npgsql.EntityFrameworkCore.PostgreSQL - - - {05a7d0b7-4ae1-4bc8-a1be-2389f1593b2d} - Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests - + + + PreserveNewest + PreserveNewest + + - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + + - + + + + - - - - \ No newline at end of file + + diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.project.json deleted file mode 100644 index 655f7ff6c..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.project.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "dependencies" : { - "Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.xproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.xproj deleted file mode 100644 index 82171253d..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 67553b48-f896-4d76-9210-95aae6707f60 - Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Properties/AssemblyInfo.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Properties/AssemblyInfo.cs index 4b9cea590..41c4767ef 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Properties/AssemblyInfo.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/Properties/AssemblyInfo.cs @@ -2,8 +2,5 @@ using System.Resources; using Xunit; -[assembly: AssemblyTitle("Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests")] -[assembly: AssemblyDescription("Functional test suite for Npgsql PostgreSQL design provider for Entity Framework Core")] - // There seem to be some issues running in parallel... See #23 [assembly: CollectionBehavior(DisableTestParallelization = true)] diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/project.json deleted file mode 100644 index 409ce0558..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests/project.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "buildOptions": { - "preserveCompilationContext": true, - "copyToOutput": { - "include": [ - "ReverseEngineering/**/*.expected", - "ReverseEngineering/**/*.sql" - ] - } - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests": { - "target": "project" - } - }, - "publishOptions": { - "include": [ - "ReverseEngineering/**/*.expected", - "ReverseEngineering/**/*.sql" - ] - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.1.0", - "type": "platform" - } - } - }, - "net451": { - "frameworkAssemblies": { - "System.Threading.Tasks": { "version": "4.0.0.0", "type": "build" } - } - } - } -} diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/DataAnnotationNpgsqlTest.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/DataAnnotationNpgsqlTest.cs index fd7e31886..0af917756 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/DataAnnotationNpgsqlTest.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/DataAnnotationNpgsqlTest.cs @@ -37,5 +37,31 @@ public override void MaxLengthAttribute_throws_while_inserting_value_longer_than { // Npgsql does not support length } + + [Fact] + public override ModelBuilder DatabaseGeneratedOption_configures_the_property_correctly() + { + var modelBuilder = CreateModelBuilder(); + + modelBuilder.Entity(); + + var entity = modelBuilder.Model.FindEntityType(typeof(GeneratedEntity)); + + var id = entity.FindProperty(nameof(GeneratedEntity.Id)); + Assert.Equal(ValueGenerated.Never, id.ValueGenerated); + Assert.False(id.RequiresValueGenerator); + + var identity = entity.FindProperty(nameof(GeneratedEntity.Identity)); + Assert.Equal(ValueGenerated.OnAdd, identity.ValueGenerated); + Assert.False(identity.RequiresValueGenerator); + + var version = entity.FindProperty(nameof(GeneratedEntity.Version)); + Assert.Equal(ValueGenerated.OnAddOrUpdate, version.ValueGenerated); + Assert.False(version.RequiresValueGenerator); + + Validate(modelBuilder); + + return modelBuilder; + } } } diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/MigrationsNpgsqlTest.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/MigrationsNpgsqlTest.cs index 9d8f8a6b8..4a991bbed 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/MigrationsNpgsqlTest.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/MigrationsNpgsqlTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Data; using System.Data.Common; @@ -15,6 +15,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests { public class MigrationsNpgsqlTest : MigrationsTestBase { + + private const string FileLineEnding = @" +"; + public MigrationsNpgsqlTest(MigrationsNpgsqlFixture fixture) : base(fixture) { @@ -22,12 +26,94 @@ public MigrationsNpgsqlTest(MigrationsNpgsqlFixture fixture) public override void Can_generate_idempotent_up_scripts() { - Assert.Throws(() => base.Can_generate_idempotent_up_scripts()); + base.Can_generate_idempotent_up_scripts(); + + Assert.Equal( +@"CREATE TABLE IF NOT EXISTS ""__EFMigrationsHistory"" ( + ""MigrationId"" varchar(150) NOT NULL, + ""ProductVersion"" varchar(32) NOT NULL, + CONSTRAINT ""PK___EFMigrationsHistory"" PRIMARY KEY (""MigrationId"") +); + + +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000001_Migration1') THEN + CREATE TABLE ""Table1"" ( + ""Id"" int4 NOT NULL, + CONSTRAINT ""PK_Table1"" PRIMARY KEY (""Id"") + ); + END IF; +END $$; + +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000001_Migration1') THEN + INSERT INTO ""__EFMigrationsHistory"" (""MigrationId"", ""ProductVersion"") + VALUES ('00000000000001_Migration1', '7.0.0-test'); + END IF; +END $$; + +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000002_Migration2') THEN + ALTER TABLE ""Table1"" RENAME TO ""Table2""; + END IF; +END $$; + +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000002_Migration2') THEN + INSERT INTO ""__EFMigrationsHistory"" (""MigrationId"", ""ProductVersion"") + VALUES ('00000000000002_Migration2', '7.0.0-test'); + END IF; +END $$; + +DO $$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000003_Migration3') THEN + INSERT INTO ""__EFMigrationsHistory"" (""MigrationId"", ""ProductVersion"") + VALUES ('00000000000003_Migration3', '7.0.0-test'); + END IF; +END $$; +", Sql.Replace(Environment.NewLine, FileLineEnding)); } public override void Can_generate_idempotent_down_scripts() { - Assert.Throws(() => base.Can_generate_idempotent_down_scripts()); + base.Can_generate_idempotent_down_scripts(); + + Assert.Equal(@" +DO $$ +BEGIN + IF EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000002_Migration2') THEN + ALTER TABLE ""Table2"" RENAME TO ""Table1""; + END IF; +END $$; + +DO $$ +BEGIN + IF EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000002_Migration2') THEN + DELETE FROM ""__EFMigrationsHistory"" + WHERE ""MigrationId"" = '00000000000002_Migration2'; + END IF; +END $$; + +DO $$ +BEGIN + IF EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000001_Migration1') THEN + DROP TABLE ""Table1""; + END IF; +END $$; + +DO $$ +BEGIN + IF EXISTS(SELECT 1 FROM ""__EFMigrationsHistory"" WHERE ""MigrationId"" = '00000000000001_Migration1') THEN + DELETE FROM ""__EFMigrationsHistory"" + WHERE ""MigrationId"" = '00000000000001_Migration1'; + END IF; +END $$; +", Sql.Replace(Environment.NewLine, FileLineEnding)); } protected override void AssertFirstMigration(DbConnection connection) @@ -40,7 +126,7 @@ Id int4 NOT NULL ColumnWithDefaultToDrop int4 NULL DEFAULT 0 ColumnWithDefaultToAlter int4 NULL DEFAULT 1 ", - sql); + sql.Replace(Environment.NewLine, FileLineEnding)); } protected override void BuildSecondMigration(MigrationBuilder migrationBuilder) @@ -68,7 +154,7 @@ Id int4 NOT NULL ColumnWithDefaultToDrop int4 NULL DEFAULT 0 ColumnWithDefaultToAlter int4 NULL DEFAULT 1 ", - sql); + sql.Replace(Environment.NewLine, FileLineEnding)); } private string GetDatabaseSchemaAsync(DbConnection connection) diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.csproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.csproj index a135e78a2..82f576357 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.csproj +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.csproj @@ -1,128 +1,34 @@ - - + + - Debug - AnyCPU - {05A7D0B7-4AE1-4BC8-A1BE-2389F1593B2D} - Library - Properties - Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests - Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests - true - v4.5.1 - 512 - + net452;netcoreapp1.1 - - true - full - false - bin\Debug\ - NET451;DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - NET451;TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + PreserveNewest + PreserveNewest + + + PreserveNewest + + - - {8edced17-2d1d-45be-9b61-0f715876da94} - Npgsql.EntityFrameworkCore.PostgreSQL.Design - - - {FADDA2D1-03B4-4DEF-8D24-DD1CA4E81F4A} - Npgsql.EntityFrameworkCore.PostgreSQL - + + + - + + + + + + + + + - - \ No newline at end of file + + diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.project.json deleted file mode 100644 index 74d46d577..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "dependencies" : { - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0", - "Microsoft.Extensions.Configuration.Json": "1.1.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", - "Npgsql": "3.1.9" - }, - "frameworks": { - "net451": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.xproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.xproj deleted file mode 100644 index 116e9bd2b..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2ff9c05f-bbf1-4ae0-ab73-017751def4de - Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Properties/AssemblyInfo.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Properties/AssemblyInfo.cs index e05281089..d5920291b 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Properties/AssemblyInfo.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/Properties/AssemblyInfo.cs @@ -2,5 +2,3 @@ using System.Resources; using Xunit; -[assembly: AssemblyTitle("Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests")] -[assembly: AssemblyDescription("Functional test suite for Npgsql PostgreSQL provider for Entity Framework Core")] diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/project.json deleted file mode 100644 index 0509c0648..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "buildOptions": { - "copyToOutput": { - "include": "**/*.sql" - } - }, - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0", - "Microsoft.Extensions.Configuration.Json": "1.1.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.1.0", - "Npgsql": "3.1.9" - }, - "publishOptions": { - "include": "**/*.sql", - "includeFiles": "config.json", - "exclude": [ - "obj/**", - "bin/**" - ] - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.1.0", - "type": "platform" - } - } - }, - "net451": { - "frameworkAssemblies": { - "System.Threading.Tasks": { "version": "4.0.0.0", "type": "build" } - } - } - } -} diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Migrations/NpgsqlMigrationSqlGeneratorTest.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Migrations/NpgsqlMigrationSqlGeneratorTest.cs index d08c1fc00..dfe3c9871 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Migrations/NpgsqlMigrationSqlGeneratorTest.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Migrations/NpgsqlMigrationSqlGeneratorTest.cs @@ -307,7 +307,7 @@ public override void AlterColumnOperation() Assert.Equal( @"ALTER TABLE ""dbo"".""People"" ALTER COLUMN ""LuckyNumber"" TYPE int;" + EOL + @"ALTER TABLE ""dbo"".""People"" ALTER COLUMN ""LuckyNumber"" SET NOT NULL;" + EOL + - @"ALTER TABLE ""dbo"".""People"" ALTER COLUMN ""LuckyNumber"" SET DEFAULT 7", + @"ALTER TABLE ""dbo"".""People"" ALTER COLUMN ""LuckyNumber"" SET DEFAULT 7;" + EOL, Sql); } @@ -318,7 +318,7 @@ public override void AlterColumnOperation_without_column_type() Assert.Equal( @"ALTER TABLE ""People"" ALTER COLUMN ""LuckyNumber"" TYPE int4;" + EOL + @"ALTER TABLE ""People"" ALTER COLUMN ""LuckyNumber"" SET NOT NULL;" + EOL + - @"ALTER TABLE ""People"" ALTER COLUMN ""LuckyNumber"" DROP DEFAULT", + @"ALTER TABLE ""People"" ALTER COLUMN ""LuckyNumber"" DROP DEFAULT;" + EOL, Sql); } @@ -480,7 +480,7 @@ public void AlterColumnOperation_with_defaultValue() Assert.Equal( "ALTER TABLE \"People\" ALTER COLUMN \"Name\" TYPE varchar(30);" + EOL + "ALTER TABLE \"People\" ALTER COLUMN \"Name\" SET NOT NULL;" + EOL + - "ALTER TABLE \"People\" ALTER COLUMN \"Name\" DROP DEFAULT", + "ALTER TABLE \"People\" ALTER COLUMN \"Name\" DROP DEFAULT;" + EOL, Sql); } @@ -592,6 +592,19 @@ public void CreateTableOperation_with_system_column() Sql); } + [Fact] + public void AddColumnOperation_with_system_column() + { + Generate(new AddColumnOperation + { + Table = "foo", + Schema = "public", + Name = "xmin" + }); + + Assert.Empty(Sql); + } + [Fact] public void DropColumnOperation_with_system_column() { diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.csproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.csproj index a9d045648..1f94a468a 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.csproj +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.csproj @@ -1,81 +1,27 @@ - - - + + - Debug - AnyCPU - {E1D99AD4-D88B-42BA-86DF-90B98B2E9A01} - Library - Properties - Npgsql.EntityFrameworkCore.PostgreSQL.Tests - Npgsql.EntityFrameworkCore.PostgreSQL.Tests - v4.5.1 - 512 + net452;netcoreapp1.1 - - true - full - false - bin\Debug\ - NET451;DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - NET451;TRACE - prompt - 4 - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + + - + + + - - {fadda2d1-03b4-4def-8d24-dd1ca4e81f4a} - Npgsql.EntityFrameworkCore.PostgreSQL - + + + + + + + + - - - \ No newline at end of file + + diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.project.json deleted file mode 100644 index fe74cb37d..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "dependencies" : { - "Microsoft.Extensions.Logging": "1.1.0-*", - "Microsoft.EntityFrameworkCore": "1.1.0-*", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0-*", - "Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0-*", - "Npgsql": "3.1.5" - }, - "frameworks": { - "net451": {} - }, - "runtimes": { - "win": {} - } -} diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.xproj b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.xproj deleted file mode 100644 index 6d99a1581..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Npgsql.EntityFrameworkCore.PostgreSQL.Tests.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0.25420 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 6584213e-212a-4262-810d-e121a7e737f1 - Npgsql.EntityFrameworkCore.PostgreSQL.Tests - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Properties/AssemblyInfo.cs b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Properties/AssemblyInfo.cs index 153063639..cb774b2b1 100644 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Properties/AssemblyInfo.cs +++ b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/Properties/AssemblyInfo.cs @@ -2,18 +2,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// 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("EntityFramework7.Npgsql.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EntityFramework7.Npgsql.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[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. @@ -21,16 +9,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("e1d99ad4-d88b-42ba-86df-90b98b2e9a01")] - -// 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 Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/project.json b/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/project.json deleted file mode 100644 index 10e1a16aa..000000000 --- a/test/Npgsql.EntityFrameworkCore.PostgreSQL.Tests/project.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "dependencies": { - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.Extensions.Logging": "1.1.0", - "Microsoft.EntityFrameworkCore": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational": "1.1.0", - "Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0", - "Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0", - "Npgsql": "3.1.9" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.1.0", - "type": "platform" - } - } - }, - "net451": { - "frameworkAssemblies": { - "System.Threading.Tasks": { "version": "4.0.0.0", "type": "build" } - } - } - } -}