提交 4007b2ce 编写于 作者: S Shay Rojansky

Everything compiles with latest rc2

Note that no tests have been executed and the provider is probably still
broken in some ways (this is just a first step).

Fixes #17
上级 dcb367e7
......@@ -16,3 +16,5 @@ artifacts/
# Roslyn cache directories
*.ide/
*.lock.json
.build
TestResult.xml
......@@ -6,6 +6,6 @@
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="AspNetRelease" value="https://www.myget.org/F/aspnetrelease/api/v3/index.json" />
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="NpgsqlUnstable" value="https://www.myget.org/F/npgsql-unstable/api/v3/index.json" />
</packageSources>
</configuration>
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
\ No newline at end of file
$ErrorActionPreference = "Stop"
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
{
while($true)
{
try
{
Invoke-WebRequest $url -OutFile $downloadLocation
break
}
catch
{
$exceptionMessage = $_.Exception.Message
Write-Host "Failed to download '$url': $exceptionMessage"
if ($retries -gt 0) {
$retries--
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
Start-Sleep -Seconds 10
}
else
{
$exception = $_.Exception
throw $exception
}
}
}
}
cd $PSScriptRoot
$repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if ($env:KOREBUILD_ZIP)
{
$koreBuildZip=$env:KOREBUILD_ZIP
}
$buildFolder = ".build"
$buildFile="$buildFolder\KoreBuild.ps1"
if (!(Test-Path $buildFolder)) {
Write-Host "Downloading KoreBuild from $koreBuildZip"
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
New-Item -Path "$tempFolder" -Type directory | Out-Null
$localZipFile="$tempFolder\korebuild.zip"
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
New-Item -Path "$buildFolder" -Type directory | Out-Null
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse
# Cleanup
if (Test-Path $tempFolder) {
Remove-Item -Recurse -Force $tempFolder
}
}
&"$buildFile" $args
\ No newline at end of file
#!/usr/bin/env bash
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP
fi
buildFolder=".build"
buildFile="$buildFolder/KoreBuild.sh"
if test ! -d $buildFolder; then
echo "Downloading KoreBuild from $koreBuildZip"
tempFolder="/tmp/KoreBuild-$(uuidgen)"
mkdir $tempFolder
localZipFile="$tempFolder/korebuild.zip"
retries=6
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
do
echo "Failed to download '$koreBuildZip'"
if [ "$retries" -le 0 ]; then
exit 1
fi
retries=$((retries - 1))
echo "Waiting 10 seconds before retrying. Retries left: $retries"
sleep 10s
done
unzip -q -d $tempFolder $localZipFile
mkdir $buildFolder
cp -r $tempFolder/**/build/** $buildFolder
chmod +x $buildFile
# Cleanup
if test ! -d $tempFolder; then
rm -rf $tempFolder
fi
fi
$buildFile -r $repoFolder "$@"
\ No newline at end of file
{
"projects": [ "src", "test" ]
}
......@@ -3,12 +3,23 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.Scaffolding.Metadata;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Utilities;
using Npgsql;
namespace Microsoft.Data.Entity.Scaffolding.Metadata
namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata
{
class NpgsqlColumnModel : ColumnModel
public class NpgsqlColumnModelAnnotations
{
private readonly ColumnModel _column;
public NpgsqlColumnModelAnnotations([NotNull] ColumnModel column)
{
Check.NotNull(column, nameof(column));
_column = column;
}
/// <summary>
/// Identifies PostgreSQL serial columns.
/// These columns are configured with a default value coming from a specifically-named sequence.
......@@ -16,6 +27,15 @@ class NpgsqlColumnModel : ColumnModel
/// <remarks>
/// See http://www.postgresql.org/docs/current/static/datatype-numeric.html
/// </remarks>
public bool IsSerial { get; set; }
public bool IsSerial
{
get
{
var value = _column[NpgsqlDatabaseModelAnnotationNames.IsSerial];
return value is bool && (bool)value;
}
[param: CanBeNull]
set { _column[NpgsqlDatabaseModelAnnotationNames.IsSerial] = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata
{
class NpgsqlDatabaseModelAnnotationNames
{
public const string Prefix = "NpgsqlDatabaseModel:";
public const string IsSerial = Prefix + "IsSerial";
public const string Expression = Prefix + "Expression";
}
}
using JetBrains.Annotations;
namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata
{
public static class NpgsqlDatabaseModelExtensions
{
public static NpgsqlColumnModelAnnotations Npgsql([NotNull] this ColumnModel column)
=> new NpgsqlColumnModelAnnotations(column);
public static NpgsqlIndexModelAnnotations Npgsql([NotNull] this IndexModel index)
=> new NpgsqlIndexModelAnnotations(index);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.Scaffolding.Metadata;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Utilities;
using Npgsql;
namespace Microsoft.Data.Entity.Scaffolding.Metadata
namespace Microsoft.EntityFrameworkCore.Scaffolding.Metadata
{
public class NpgsqlIndexModel : IndexModel
public class NpgsqlIndexModelAnnotations
{
private readonly IndexModel _index;
public NpgsqlIndexModelAnnotations([NotNull] IndexModel index)
{
Check.NotNull(index, nameof(index));
_index = index;
}
/// <summary>
/// If the index contains an expression (rather than simple column references), the expression is contained here.
/// This is currently unsupported and will be ignored.
/// </summary>
public string Expression { get; set; }
public string Expression
{
get { return _index[NpgsqlDatabaseModelAnnotationNames.Expression] as string; }
[param: CanBeNull] set { _index[NpgsqlDatabaseModelAnnotationNames.Expression] = value; }
}
}
}
......@@ -7,11 +7,11 @@
<ProjectGuid>{8EDCED17-2D1D-45BE-9B61-0F715876DA94}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EntityFramework7.Npgsql.Design</RootNamespace>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL.Design</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\Npgsql.snk</AssemblyOriginatorKeyFile>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.Design</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
......@@ -32,82 +32,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\EntityFramework.Core.7.0.0-rc2-16583\lib\net451\EntityFramework.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.Relational, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\EntityFramework.Relational.7.0.0-rc2-16583\lib\net451\EntityFramework.Relational.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.Relational.Design, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\EntityFramework.Relational.Design.7.0.0-rc2-16583\lib\net451\EntityFramework.Relational.Design.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Caching.Abstractions.1.0.0-rc2-15948\lib\net451\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Memory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Caching.Memory.1.0.0-rc2-15948\lib\net451\Microsoft.Extensions.Caching.Memory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Binder.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.1.0.0-rc2-15888\lib\net451\Microsoft.Extensions.DependencyInjection.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0-rc2-15888\lib\net451\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.1.0.0-rc2-15926\lib\net451\Microsoft.Extensions.Logging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0-rc2-15926\lib\net451\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.OptionsModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.OptionsModel.1.0.0-rc2-15904\lib\net451\Microsoft.Extensions.OptionsModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.1.0.0-rc2-15937\lib\net451\Microsoft.Extensions.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Remotion.Linq, Version=2.0.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
<HintPath>..\..\packages\Remotion.Linq.2.0.1\lib\net45\Remotion.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.0.0-rc2-23616\lib\dotnet5.2\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -117,27 +45,21 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Metadata\NpgsqlColumnModel.cs" />
<Compile Include="Metadata\NpgsqlIndexModel.cs" />
<Compile Include="..\Shared\Check.cs">
<Link>Check.cs</Link>
</Compile>
<Compile Include="Metadata\NpgsqlDatabaseModelExtensions.cs" />
<Compile Include="Metadata\NpgsqlIndexModelAnnotations.cs" />
<Compile Include="Metadata\NpgsqlColumnModelAnnotations.cs" />
<Compile Include="Metadata\NpgsqlDatabaseModelAnnotationNames.cs" />
<Compile Include="NpgsqlDatabaseModelFactory.cs" />
<Compile Include="NpgsqlDesignTimeServices.cs" />
<Compile Include="NpgsqlScaffoldingModelFactory.cs" />
<Compile Include="NpgsqlTableSelectionSetExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utilities\Check.cs" />
<Compile Include="Utilities\LoggingExtensions.cs" />
<Compile Include="Utilities\SharedTypeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Npgsql.EntityFrameworkCore.PostgreSQL\Npgsql.EntityFrameworkCore.PostgreSQL.csproj">
<Project>{fadda2d1-03b4-4def-8d24-dd1ca4e81f4a}</Project>
<Name>EntityFramework7.Npgsql</Name>
</ProjectReference>
<ProjectReference Include="..\Npgsql\Npgsql.csproj">
<Project>{9D13B739-62B1-4190-B386-7A9547304EB3}</Project>
<Name>Npgsql</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
......@@ -146,7 +68,12 @@
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\Npgsql.EntityFrameworkCore.PostgreSQL\Npgsql.EntityFrameworkCore.PostgreSQL.csproj">
<Project>{fadda2d1-03b4-4def-8d24-dd1ca4e81f4a}</Project>
<Name>Npgsql.EntityFrameworkCore.PostgreSQL</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......@@ -155,4 +82,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
\ No newline at end of file
......@@ -3,16 +3,14 @@
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Internal;
using Microsoft.Data.Entity.Scaffolding.Internal;
using Microsoft.Data.Entity.Scaffolding.Metadata;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.Logging;
using Npgsql;
namespace Microsoft.Data.Entity.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding
{
public class NpgsqlDatabaseModelFactory : IDatabaseModelFactory
{
......@@ -20,7 +18,7 @@ public class NpgsqlDatabaseModelFactory : IDatabaseModelFactory
private TableSelectionSet _tableSelectionSet;
private DatabaseModel _databaseModel;
private Dictionary<string, TableModel> _tables;
private Dictionary<string, NpgsqlColumnModel> _tableColumns;
private Dictionary<string, ColumnModel> _tableColumns;
private static string TableKey(TableModel table) => TableKey(table.Name, table.SchemaName);
private static string TableKey(string name, string schema) => $"\"{schema}\".\"{name}\"";
......@@ -41,7 +39,7 @@ private void ResetState()
_tableSelectionSet = null;
_databaseModel = new DatabaseModel();
_tables = new Dictionary<string, TableModel>();
_tableColumns = new Dictionary<string, NpgsqlColumnModel>(StringComparer.OrdinalIgnoreCase);
_tableColumns = new Dictionary<string, ColumnModel>(StringComparer.OrdinalIgnoreCase);
}
public DatabaseModel Create(string connectionString, TableSelectionSet tableSelectionSet)
......@@ -159,7 +157,7 @@ private void GetColumns()
}
var table = _tables[TableKey(tableName, schemaName)];
var column = new NpgsqlColumnModel
var column = new ColumnModel
{
Table = table,
Name = columnName,
......@@ -179,7 +177,7 @@ private void GetColumns()
defaultValue == $"nextval('\"{tableName}_{columnName}_seq\"'::regclass)")
)
{
column.IsSerial = true;
column.Npgsql().IsSerial = true;
column.ValueGenerated = ValueGenerated.OnAdd;
column.DefaultValue = null;
}
......@@ -219,17 +217,13 @@ void GetIndexes()
var indexName = reader.GetString(2);
if (!_tableSelectionSet.Allows(schemaName, tableName))
{
continue;
}
TableModel table;
if (!_tables.TryGetValue(TableKey(tableName, schemaName), out table))
{
continue;
}
var index = new NpgsqlIndexModel
var index = new IndexModel
{
Table = table,
Name = indexName,
......@@ -241,14 +235,23 @@ void GetIndexes()
var columnIndices = reader.GetFieldValue<short[]>(4);
if (columnIndices.Any(i => i == 0))
{
if (reader.IsDBNull(5)) {
if (reader.IsDBNull(5))
throw new Exception($"Seen 0 in indkey for index {indexName} but indexprs is null");
}
index.Expression = reader.GetString(5);
index.Npgsql().Expression = reader.GetString(5);
}
else foreach (var column in columnIndices.Select(i => table.Columns[i - 1]))
else
{
index.Columns.Add(column);
var columns = (List<ColumnModel>)table.Columns;
for (var ordinal = 0; ordinal < columnIndices.Length; ordinal++)
{
var columnIndex = columnIndices[ordinal] - 1;
index.IndexColumns.Add(new IndexColumnModel
{
Index = index,
Column = columns[columnIndex],
Ordinal = ordinal // TODO: One-based or zero-based?
});
}
}
}
}
......@@ -279,10 +282,9 @@ void GetConstraints()
var tableName = reader.GetString(1);
if (!_tableSelectionSet.Allows(schemaName, tableName))
{
continue;
}
var table = _tables[TableKey(tableName, schemaName)];
var columns = (List<ColumnModel>)table.Columns;
var constraintName = reader.GetString(2);
var constraintType = reader.GetChar(3);
......@@ -291,9 +293,7 @@ void GetConstraints()
case 'p':
var pkColumnIndices = reader.GetFieldValue<short[]>(4);
for (var i = 0; i < pkColumnIndices.Length; i++)
{
table.Columns[pkColumnIndices[i] - 1].PrimaryKeyOrdinal = i + 1;
}
columns[pkColumnIndices[i] - 1].PrimaryKeyOrdinal = i + 1;
continue;
case 'f':
......@@ -301,9 +301,7 @@ void GetConstraints()
var foreignTableName = reader.GetString(6);
TableModel principalTable;
if (!_tables.TryGetValue(TableKey(foreignTableName, foreignSchemaName), out principalTable))
{
continue;
}
var fkInfo = new ForeignKeyModel
{
......@@ -313,13 +311,17 @@ void GetConstraints()
OnDelete = ConvertToReferentialAction(reader.GetChar(8))
};
foreach (var column in reader.GetFieldValue<short[]>(4).Select(i => table.Columns[i - 1])) {
fkInfo.Columns.Add(column);
}
var columnIndices = reader.GetFieldValue<short[]>(4);
var principalColumnIndices = reader.GetFieldValue<short[]>(7);
if (columnIndices.Length != principalColumnIndices.Length)
throw new Exception("Got varying lengths for column and principal column indices");
foreach (var principalColumn in reader.GetFieldValue<short[]>(7).Select(i => principalTable.Columns[i - 1])) {
fkInfo.PrincipalColumns.Add(principalColumn);
}
for (var ordinal = 0; ordinal < columnIndices.Length; ordinal++)
fkInfo.Columns.Add(new ForeignKeyColumnModel {
Column = columns[columnIndices[ordinal] - 1],
PrincipalColumn = columns[principalColumnIndices[ordinal] - 1],
Ordinal = ordinal
});
table.ForeignKeys.Add(fkInfo);
break;
......@@ -380,10 +382,10 @@ void GetSequences()
var ownerColumn = reader.GetString(10);
TableModel ownerTableModel;
NpgsqlColumnModel ownerColumnModel;
ColumnModel ownerColumnModel;
if (_tables.TryGetValue(TableKey(ownerTable, ownerSchema), out ownerTableModel) &&
_tableColumns.TryGetValue(ColumnKey(ownerTableModel, ownerColumn), out ownerColumnModel) &&
ownerColumnModel.IsSerial)
ownerColumnModel.Npgsql().IsSerial)
{
continue;
}
......
using JetBrains.Annotations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Scaffolding.Internal;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Storage.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Data.Entity.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding
{
public class NpgsqlDesignTimeServices
{
public virtual void ConfigureDesignTimeServices([NotNull] IServiceCollection serviceCollection)
{
serviceCollection
public virtual IServiceCollection ConfigureDesignTimeServices([NotNull] IServiceCollection serviceCollection)
=> serviceCollection
.AddSingleton<IScaffoldingModelFactory, NpgsqlScaffoldingModelFactory>()
.AddSingleton<IRelationalAnnotationProvider, NpgsqlAnnotationProvider>()
.AddSingleton<IRelationalTypeMapper, NpgsqlTypeMapper>()
.AddSingleton<IDatabaseModelFactory, NpgsqlDatabaseModelFactory>();
}
}
}
......@@ -2,16 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Builders;
using Microsoft.Data.Entity.Scaffolding.Internal;
using Microsoft.Data.Entity.Scaffolding.Metadata;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Logging;
namespace Microsoft.Data.Entity.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding
{
public class NpgsqlScaffoldingModelFactory : RelationalScaffoldingModelFactory
{
......@@ -46,8 +45,8 @@ protected override KeyBuilder VisitPrimaryKey(EntityTypeBuilder builder, TableMo
// override this behavior.
// TODO use KeyConvention directly to detect when it will be applied
var pkColumns = table.Columns.Where(c => c.PrimaryKeyOrdinal.HasValue).Cast<NpgsqlColumnModel>().ToList();
if (pkColumns.Count != 1 || pkColumns[0].IsSerial)
var pkColumns = table.Columns.Where(c => c.PrimaryKeyOrdinal.HasValue).ToList();
if (pkColumns.Count != 1 || pkColumns[0].Npgsql().IsSerial)
{
return keyBuilder;
}
......@@ -67,10 +66,10 @@ protected override KeyBuilder VisitPrimaryKey(EntityTypeBuilder builder, TableMo
[CanBeNull]
protected override IndexBuilder VisitIndex(EntityTypeBuilder builder, IndexModel index)
{
var npgsqlIndex = (NpgsqlIndexModel)index;
if (npgsqlIndex.Expression != null)
var expression = index.Npgsql().Expression;
if (expression != null)
{
Logger.LogWarning($"Ignoring unsupported index {index.Name} which contains an expression ({npgsqlIndex.Expression})");
Logger.LogWarning($"Ignoring unsupported index {index.Name} which contains an expression ({expression})");
return null;
}
......
using System.Linq;
using System;
using System.Linq;
using JetBrains.Annotations;
namespace Microsoft.Data.Entity.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding
{
internal static class NpgsqlTableSelectionSetExtensions
{
......@@ -14,17 +15,33 @@ public static bool Allows(this TableSelectionSet _tableSelectionSet, [NotNull] s
return true;
}
if (_tableSelectionSet.Schemas.Contains(schemaName))
var result = false;
foreach (var schemaSelection in _tableSelectionSet.Schemas)
if (EqualsWithQuotes(schemaSelection.Text, schemaName))
{
schemaSelection.IsMatched = true;
result = true;
}
foreach (var tableSelection in _tableSelectionSet.Tables)
{
return true;
var components = tableSelection.Text.Split('.');
if (components.Length == 1
? EqualsWithQuotes(components[0], tableName)
: EqualsWithQuotes(components[0], schemaName) && EqualsWithQuotes(components[1], tableName))
{
tableSelection.IsMatched = true;
result = true;
}
}
return _tableSelectionSet.Tables.Contains($"{schemaName}.{tableName}")
|| _tableSelectionSet.Tables.Contains($"[{schemaName}].[{tableName}]")
|| _tableSelectionSet.Tables.Contains($"{schemaName}.[{tableName}]")
|| _tableSelectionSet.Tables.Contains($"[{schemaName}].{tableName}")
|| _tableSelectionSet.Tables.Contains($"{tableName}")
|| _tableSelectionSet.Tables.Contains($"[{tableName}]");
return result;
}
static bool EqualsWithQuotes(string expr, string name) =>
expr[0] == '"' && expr[expr.Length - 1] == '"'
? expr.Substring(0, expr.Length - 2).Equals(name)
: expr.Equals(name, StringComparison.OrdinalIgnoreCase);
}
}
using System.Reflection;
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.Design")]
[assembly: AssemblyTitle("Npgsql.EntityFrameworkCore.PostgreSQL.Design")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EntityFramework7.Npgsql.Design")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8edced17-2d1d-45be-9b61-0f715876da94")]
// 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")]
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Internal;
namespace Microsoft.Data.Entity.Utilities
{
[DebuggerStepThrough]
internal static class Check
{
[ContractAnnotation("value:null => halt")]
public static T NotNull<T>([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName)
{
if (ReferenceEquals(value, null))
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentNullException(parameterName);
}
return value;
}
[ContractAnnotation("value:null => halt")]
public static T NotNull<T>(
[NoEnumeration] T value,
[InvokerParameterName] [NotNull] string parameterName,
[NotNull] string propertyName)
{
if (ReferenceEquals(value, null))
{
NotEmpty(parameterName, nameof(parameterName));
NotEmpty(propertyName, nameof(propertyName));
throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName));
}
return value;
}
[ContractAnnotation("value:null => halt")]
public static IReadOnlyList<T> NotEmpty<T>(IReadOnlyList<T> value, [InvokerParameterName] [NotNull] string parameterName)
{
NotNull(value, parameterName);
if (value.Count == 0)
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));
}
return value;
}
[ContractAnnotation("value:null => halt")]
public static string NotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
{
Exception e = null;
if (ReferenceEquals(value, null))
{
e = new ArgumentNullException(parameterName);
}
else if (value.Trim().Length == 0)
{
e = new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
}
if (e != null)
{
NotEmpty(parameterName, nameof(parameterName));
throw e;
}
return value;
}
public static string NullButNotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
{
if (!ReferenceEquals(value, null)
&& value.Length == 0)
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
}
return value;
}
public static IReadOnlyList<T> HasNoNulls<T>(IReadOnlyList<T> value, [InvokerParameterName] [NotNull] string parameterName)
where T : class
{
NotNull(value, parameterName);
if (value.Any(e => e == null))
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(parameterName);
}
return value;
}
public static T IsDefined<T>(T value, [InvokerParameterName] [NotNull] string parameterName)
where T : struct
{
if (!Enum.IsDefined(typeof(T), value))
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.InvalidEnumValue(parameterName, typeof(T)));
}
return value;
}
public static Type ValidEntityType(Type value, [InvokerParameterName] [NotNull] string parameterName)
{
if (!value.GetTypeInfo().IsClass)
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.InvalidEntityType(parameterName, value));
}
return value;
}
}
}
{
"version": "3.1.0-*",
"version": "1.0.0-*",
"authors": [
"Shay Rojansky"
],
"description": "Design-time Entity Framework Functionality for PostgreSQL",
"description": "Design-time Entity Framework Core Functionality for PostgreSQL",
"iconUrl": "http://www.npgsql.org/img/postgresql.gif",
"repository": {
"type": "git",
"url": "git://github.com/npgsql/npgsql"
},
"compile": "../Shared/*.cs",
"compilationOptions": {
"keyFile": "../../Npgsql.snk"
"keyFile": "../../Npgsql.snk",
"warningsAsErrors": true
},
"dependencies" : {
"EntityFramework.Core": "7.0.0-rc2-16563",
"EntityFramework.Relational": "7.0.0-rc2-16563",
"EntityFramework.Relational.Design": "7.0.0-rc2-16563",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational.Design": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-*",
"EntityFramework7.Npgsql": "3.1.0-*",
"Npgsql": "3.1.0-*"
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0-*"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Collections": { "version": "4.0.0.0", "type": "build" },
"System.Reflection": { "version": "4.0.0.0", "type": "build" },
"System.Diagnostics.Contracts": { "version": "4.0.0.0", "type": "build" },
"System.Linq.Expressions": { "version": "4.0.0.0", "type": "build" },
"System.Runtime": { "version": "4.0.0.0", "type": "build" }
}
},
"dnx451": {
"frameworkAssemblies": {
"System.Collections": "4.0.0.0",
"System.Reflection": "4.0.0.0",
"System.Diagnostics.Contracts": "4.0.0.0",
"System.Linq.Expressions": "4.0.0.0",
"System.Runtime": "4.0.0.0"
}
},
"dotnet54": {
"net451": {},
"netstandard13": {
"imports": [
"portable-net452+win81"
],
"dependencies": {
}
}
......
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Data.Common;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity
namespace Microsoft.EntityFrameworkCore
{
public static class NpgsqlDbContextOptionsExtensions
{
public static NpgsqlDbContextOptionsBuilder UseNpgsql([NotNull] this DbContextOptionsBuilder optionsBuilder, [NotNull] string connectionString)
/// <summary>
/// Configures the context to connect to a Microsoft SQL Server database.
/// </summary>
/// <param name="optionsBuilder"> A builder for setting options on the context. </param>
/// <param name="connectionString"> The connection string of the database to connect to. </param>
/// <param name="NpgsqlOptionsAction">An optional action to allow additional SQL Server specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseNpgsql(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] string connectionString,
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> NpgsqlOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotEmpty(connectionString, nameof(connectionString));
......@@ -22,11 +33,27 @@ public static NpgsqlDbContextOptionsBuilder UseNpgsql([NotNull] this DbContextOp
extension.ConnectionString = connectionString;
((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);
return new NpgsqlDbContextOptionsBuilder(optionsBuilder);
NpgsqlOptionsAction?.Invoke(new NpgsqlDbContextOptionsBuilder(optionsBuilder));
return optionsBuilder;
}
// Note: Decision made to use DbConnection not SqlConnection: Issue #772
public static NpgsqlDbContextOptionsBuilder UseNpgsql([NotNull] this DbContextOptionsBuilder optionsBuilder, [NotNull] DbConnection connection)
/// <summary>
/// Configures the context to connect to a Microsoft SQL Server database.
/// </summary>
/// <param name="optionsBuilder"> A builder for setting options on the context. </param>
/// <param name="connection">
/// An existing <see cref="DbConnection" /> to be used to connect to the database. If the connection is
/// in the open state then EF will not open or close the connection. If the connection is in the closed
/// state then EF will open and close the connection as needed.
/// </param>
/// <param name="NpgsqlOptionsAction">An optional action to allow additional SQL Server specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseNpgsql(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] DbConnection connection,
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> NpgsqlOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));
......@@ -35,9 +62,46 @@ public static NpgsqlDbContextOptionsBuilder UseNpgsql([NotNull] this DbContextOp
extension.Connection = connection;
((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);
return new NpgsqlDbContextOptionsBuilder(optionsBuilder);
NpgsqlOptionsAction?.Invoke(new NpgsqlDbContextOptionsBuilder(optionsBuilder));
return optionsBuilder;
}
/// <summary>
/// Configures the context to connect to a Microsoft SQL Server database.
/// </summary>
/// <param name="optionsBuilder"> A builder for setting options on the context. </param>
/// <param name="connectionString"> The connection string of the database to connect to. </param>
/// <param name="NpgsqlOptionsAction">An optional action to allow additional SQL Server specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] string connectionString,
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> NpgsqlOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseNpgsql(
(DbContextOptionsBuilder)optionsBuilder, connectionString, NpgsqlOptionsAction);
// Note: Decision made to use DbConnection not SqlConnection: Issue #772
/// <summary>
/// Configures the context to connect to a Microsoft SQL Server database.
/// </summary>
/// <param name="optionsBuilder"> A builder for setting options on the context. </param>
/// <param name="connection">
/// An existing <see cref="DbConnection" /> to be used to connect to the database. If the connection is
/// in the open state then EF will not open or close the connection. If the connection is in the closed
/// state then EF will open and close the connection as needed.
/// </param>
/// <param name="NpgsqlOptionsAction">An optional action to allow additional SQL Server specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseNpgsql<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] DbConnection connection,
[CanBeNull] Action<NpgsqlDbContextOptionsBuilder> NpgsqlOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>)UseNpgsql(
(DbContextOptionsBuilder)optionsBuilder, connection, NpgsqlOptionsAction);
private static NpgsqlOptionsExtension GetOrCreateExtension(DbContextOptionsBuilder optionsBuilder)
{
var existing = optionsBuilder.Options.FindExtension<NpgsqlOptionsExtension>();
......
......@@ -2,14 +2,12 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata.Builders;
using Microsoft.Data.Entity.Metadata.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity
namespace Microsoft.EntityFrameworkCore
{
public static class NpgsqlEntityTypeBuilderExtensions
{
......@@ -20,9 +18,7 @@ public static class NpgsqlEntityTypeBuilderExtensions
Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder));
Check.NullButNotEmpty(name, nameof(name));
var relationalEntityTypeBuilder = ((IInfrastructure<InternalEntityTypeBuilder>)entityTypeBuilder).GetInfrastructure()
.Npgsql(ConfigurationSource.Explicit);
relationalEntityTypeBuilder.TableName = name;
entityTypeBuilder.Metadata.Npgsql().TableName = name;
return entityTypeBuilder;
}
......@@ -42,10 +38,9 @@ public static class NpgsqlEntityTypeBuilderExtensions
Check.NullButNotEmpty(name, nameof(name));
Check.NullButNotEmpty(schema, nameof(schema));
var relationalEntityTypeBuilder = ((IInfrastructure<InternalEntityTypeBuilder>)entityTypeBuilder).GetInfrastructure()
.Npgsql(ConfigurationSource.Explicit);
relationalEntityTypeBuilder.TableName = name;
relationalEntityTypeBuilder.Schema = schema;
var relationalEntityTypeAnnotations = entityTypeBuilder.Metadata.Npgsql();
relationalEntityTypeAnnotations.TableName = name;
relationalEntityTypeAnnotations.Schema = schema;
return entityTypeBuilder;
}
......
using JetBrains.Annotations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity
namespace Microsoft.EntityFrameworkCore
{
public static class NpgsqlMetadataExtensions
{
public static IRelationalEntityTypeAnnotations Npgsql([NotNull] this IEntityType entityType)
=> new RelationalEntityTypeAnnotations(Check.NotNull(entityType, nameof(entityType)), NpgsqlAnnotationNames.Prefix);
=> new RelationalEntityTypeAnnotations(Check.NotNull(entityType, nameof(entityType)), NpgsqlFullAnnotationNames.Instance);
public static RelationalEntityTypeAnnotations Npgsql([NotNull] this EntityType entityType)
public static RelationalEntityTypeAnnotations Npgsql([NotNull] this IMutableEntityType entityType)
=> (RelationalEntityTypeAnnotations)Npgsql((IEntityType)entityType);
public static IRelationalForeignKeyAnnotations Npgsql([NotNull] this IForeignKey foreignKey)
=> new RelationalForeignKeyAnnotations(Check.NotNull(foreignKey, nameof(foreignKey)), NpgsqlAnnotationNames.Prefix);
=> new RelationalForeignKeyAnnotations(Check.NotNull(foreignKey, nameof(foreignKey)), NpgsqlFullAnnotationNames.Instance);
public static RelationalForeignKeyAnnotations Npgsql([NotNull] this ForeignKey foreignKey)
public static RelationalForeignKeyAnnotations Npgsql([NotNull] this IMutableForeignKey foreignKey)
=> (RelationalForeignKeyAnnotations)Npgsql((IForeignKey)foreignKey);
public static NpgsqlIndexAnnotations Npgsql([NotNull] this IIndex index)
public static INpgsqlIndexAnnotations Npgsql([NotNull] this IIndex index)
=> new NpgsqlIndexAnnotations(Check.NotNull(index, nameof(index)));
public static RelationalIndexAnnotations Npgsql([NotNull] this Index index)
=> Npgsql((IIndex)index);
public static RelationalIndexAnnotations Npgsql([NotNull] this IMutableIndex index)
=> (NpgsqlIndexAnnotations)Npgsql((IIndex)index);
public static IRelationalKeyAnnotations Npgsql([NotNull] this IKey key)
=> new RelationalKeyAnnotations(Check.NotNull(key, nameof(key)), NpgsqlAnnotationNames.Prefix);
=> new RelationalKeyAnnotations(Check.NotNull(key, nameof(key)), NpgsqlFullAnnotationNames.Instance);
public static RelationalKeyAnnotations Npgsql([NotNull] this Key key)
public static RelationalKeyAnnotations Npgsql([NotNull] this IMutableKey key)
=> (RelationalKeyAnnotations)Npgsql((IKey)key);
public static RelationalModelAnnotations Npgsql([NotNull] this Model model)
=> (RelationalModelAnnotations)Npgsql((IModel)model);
public static IRelationalModelAnnotations Npgsql([NotNull] this IModel model)
=> new RelationalModelAnnotations(Check.NotNull(model, nameof(model)), NpgsqlAnnotationNames.Prefix);
=> new RelationalModelAnnotations(Check.NotNull(model, nameof(model)), NpgsqlFullAnnotationNames.Instance);
public static RelationalModelAnnotations Npgsql([NotNull] this IMutableModel model)
=> (RelationalModelAnnotations)Npgsql((IModel)model);
public static IRelationalPropertyAnnotations Npgsql([NotNull] this IProperty property)
=> new RelationalPropertyAnnotations(Check.NotNull(property, nameof(property)), NpgsqlAnnotationNames.Prefix);
=> new RelationalPropertyAnnotations(Check.NotNull(property, nameof(property)), NpgsqlFullAnnotationNames.Instance);
public static RelationalPropertyAnnotations Npgsql([NotNull] this Property property)
public static RelationalPropertyAnnotations Npgsql([NotNull] this IMutableProperty property)
=> (RelationalPropertyAnnotations)Npgsql((IProperty)property);
}
}
......@@ -2,20 +2,20 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Conventions.Internal;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Internal;
using Microsoft.Data.Entity.Query.ExpressionTranslators.Internal;
using Microsoft.Data.Entity.Query.Internal;
using Microsoft.Data.Entity.Query.Sql.Internal;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Storage.Internal;
using Microsoft.Data.Entity.Update.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.Data.Entity.ValueGeneration.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Internal;
using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.Sql.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore.Update.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
using Microsoft.Extensions.DependencyInjection.Extensions;
// ReSharper disable once CheckNamespace
......@@ -24,16 +24,45 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class NpgsqlEntityFrameworkServicesBuilderExtensions
{
public static EntityFrameworkServicesBuilder AddNpgsql([NotNull] this EntityFrameworkServicesBuilder builder)
/// <summary>
/// <para>
/// Adds the services required by the Npgsql database provider for Entity Framework
/// to an <see cref="IServiceCollection" />. You use this method when using dependency injection
/// in your application, such as with ASP.NET. For more information on setting up dependency
/// injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
/// </para>
/// <para>
/// You only need to use this functionality when you want Entity Framework to resolve the services it uses
/// from an external <see cref="IServiceCollection" />. If you are not using an external
/// <see cref="IServiceCollection" /> Entity Framework will take care of creating the services it requires.
/// </para>
/// </summary>
/// <example>
/// <code>
/// public void ConfigureServices(IServiceCollection services)
/// {
/// var connectionString = "connection string to database";
///
/// services
/// .AddEntityFrameworkSqlServer()
/// .AddDbContext&lt;MyContext&gt;(options => options.UseNpgsql(connectionString));
/// }
/// </code>
/// </example>
/// <param name="services"> The <see cref="IServiceCollection" /> to add services to. </param>
/// <returns>
/// A builder that allows further Entity Framework specific setup of the <see cref="IServiceCollection" />.
/// </returns>
public static IServiceCollection AddEntityFrameworkNpgsql([NotNull] this IServiceCollection services)
{
Check.NotNull(builder, nameof(builder));
Check.NotNull(services, nameof(services));
var service = builder.AddRelational().GetInfrastructure();
services.AddRelational();
service.TryAddEnumerable(ServiceDescriptor
services.TryAddEnumerable(ServiceDescriptor
.Singleton<IDatabaseProvider, DatabaseProvider<NpgsqlDatabaseProviderServices, NpgsqlOptionsExtension>>());
service.TryAdd(new ServiceCollection()
services.TryAdd(new ServiceCollection()
.AddSingleton<NpgsqlValueGeneratorCache>()
.AddSingleton<NpgsqlTypeMapper>()
.AddSingleton<NpgsqlSqlGenerationHelper>()
......@@ -51,7 +80,7 @@ public static EntityFrameworkServicesBuilder AddNpgsql([NotNull] this EntityFram
.AddScoped<NpgsqlHistoryRepository>()
.AddQuery());
return builder;
return services;
}
private static IServiceCollection AddQuery(this IServiceCollection serviceCollection)
......
......@@ -2,18 +2,19 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata.Conventions.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Internal
namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
public class NpgsqlModelSource : ModelSource
{
public NpgsqlModelSource(
[NotNull] IDbSetFinder setFinder,
[NotNull] ICoreConventionSetBuilder coreConventionSetBuilder)
: base(setFinder, coreConventionSetBuilder)
[NotNull] ICoreConventionSetBuilder coreConventionSetBuilder,
[NotNull] IModelCustomizer modelCustomizer,
[NotNull] IModelCacheKeyFactory modelCacheKeyFactory)
: base(setFinder, coreConventionSetBuilder, modelCustomizer, modelCacheKeyFactory)
{
}
}
......
......@@ -2,12 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Internal
namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
public class NpgsqlOptionsExtension : RelationalOptionsExtension
{
......@@ -20,11 +19,7 @@ public NpgsqlOptionsExtension([NotNull] NpgsqlOptionsExtension copyFrom)
{
}
public override void ApplyServices(EntityFrameworkServicesBuilder builder)
{
Check.NotNull(builder, nameof(builder));
builder.AddNpgsql();
}
public override void ApplyServices(IServiceCollection services)
=> Check.NotNull(services, nameof(services)).AddEntityFrameworkNpgsql();
}
}
......@@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Infrastructure
namespace Microsoft.EntityFrameworkCore.Infrastructure
{
public class NpgsqlDbContextOptionsBuilder : RelationalDbContextOptionsBuilder<NpgsqlDbContextOptionsBuilder, NpgsqlOptionsExtension>
{
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// ReSharper disable once CheckNamespace
using JetBrains.Annotations;
using Microsoft.Data.Entity.Storage;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
using Microsoft.EntityFrameworkCore.Storage;
namespace Microsoft.Data.Entity.Metadata.Conventions.Internal
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions
{
public class NpgsqlConventionSetBuilder : RelationalConventionSetBuilder
{
public NpgsqlConventionSetBuilder([NotNull] IRelationalTypeMapper typeMapper)
: base(typeMapper)
public NpgsqlConventionSetBuilder(
[NotNull] IRelationalTypeMapper typeMapper,
[CanBeNull] ICurrentDbContext currentContext,
[CanBeNull] IDbSetFinder setFinder)
: base(typeMapper, currentContext, setFinder)
{
}
......
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Microsoft.EntityFrameworkCore.Metadata
{
public interface INpgsqlIndexAnnotations : IRelationalIndexAnnotations
{
/// <summary>
/// The PostgreSQL index method to be used. Null selects the default (currently btree).
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/sql-createindex.html
/// </remarks>
string Method { get; }
}
}
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Data.Entity.Metadata
{
public interface INpgsqlPropertyAnnotations : IRelationalPropertyAnnotations
{
string SequenceName { get; }
string SequenceSchema { get; }
Sequence TryGetSequence();
}
}
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
public static class NpgsqlAnnotationNames
{
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
public class NpgsqlFullAnnotationNames : RelationalFullAnnotationNames
{
protected NpgsqlFullAnnotationNames(string prefix)
: base(prefix)
{
Serial = prefix + NpgsqlAnnotationNames.Serial;
DefaultSequenceName = prefix + NpgsqlAnnotationNames.DefaultSequenceName;
DefaultSequenceSchema = prefix + NpgsqlAnnotationNames.DefaultSequenceSchema;
SequenceName = prefix + NpgsqlAnnotationNames.SequenceName;
SequenceSchema = prefix + NpgsqlAnnotationNames.SequenceSchema;
IndexMethod = prefix + NpgsqlAnnotationNames.IndexMethod;
}
public new static NpgsqlFullAnnotationNames Instance { get; } = new NpgsqlFullAnnotationNames(NpgsqlAnnotationNames.Prefix);
public readonly string Serial;
public readonly string DefaultSequenceName;
public readonly string DefaultSequenceSchema;
public readonly string SequenceName;
public readonly string SequenceSchema;
public readonly string IndexMethod;
}
}
......@@ -3,13 +3,38 @@
using JetBrains.Annotations;
namespace Microsoft.Data.Entity.Metadata.Internal
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
public static class NpgsqlInternalMetadataBuilderExtensions
{
public static RelationalModelBuilderAnnotations Npgsql(
[NotNull] this InternalModelBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalModelBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
public static RelationalPropertyBuilderAnnotations Npgsql(
[NotNull] this InternalPropertyBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalPropertyBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
public static RelationalEntityTypeBuilderAnnotations Npgsql(
[NotNull] this InternalEntityTypeBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalEntityTypeBuilderAnnotations(builder, configurationSource, NpgsqlAnnotationNames.Prefix);
=> new RelationalEntityTypeBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
public static RelationalKeyBuilderAnnotations Npgsql(
[NotNull] this InternalKeyBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalKeyBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
public static RelationalIndexBuilderAnnotations Npgsql(
[NotNull] this InternalIndexBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalIndexBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
public static RelationalForeignKeyBuilderAnnotations Npgsql(
[NotNull] this InternalRelationshipBuilder builder,
ConfigurationSource configurationSource)
=> new RelationalForeignKeyBuilderAnnotations(builder, configurationSource, NpgsqlFullAnnotationNames.Instance);
}
}
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Data.Entity.Metadata
namespace Microsoft.EntityFrameworkCore.Metadata
{
public class NpgsqlAnnotationProvider : IRelationalAnnotationProvider
{
......
using JetBrains.Annotations;
using Microsoft.Data.Entity.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Microsoft.Data.Entity.Metadata
namespace Microsoft.EntityFrameworkCore.Metadata
{
public class NpgsqlIndexAnnotations : RelationalIndexAnnotations
public class NpgsqlIndexAnnotations : RelationalIndexAnnotations, INpgsqlIndexAnnotations
{
public NpgsqlIndexAnnotations([NotNull] IIndex index)
: base(index, NpgsqlAnnotationNames.Prefix)
: base(index, NpgsqlFullAnnotationNames.Instance)
{
}
protected NpgsqlIndexAnnotations([NotNull] RelationalAnnotations annotations)
: base(annotations)
: base(annotations, NpgsqlFullAnnotationNames.Instance)
{
}
......@@ -23,8 +23,8 @@ protected NpgsqlIndexAnnotations([NotNull] RelationalAnnotations annotations)
/// </remarks>
public string Method
{
get { return (string) Annotations.GetAnnotation(NpgsqlAnnotationNames.IndexMethod); }
set { Annotations.SetAnnotation(NpgsqlAnnotationNames.IndexMethod, value); }
get { return (string) Annotations.GetAnnotation(NpgsqlFullAnnotationNames.Instance.IndexMethod, null); }
set { Annotations.SetAnnotation(NpgsqlFullAnnotationNames.Instance.IndexMethod, null, value); }
}
}
}
......@@ -4,13 +4,14 @@
using System;
using System.Text;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Storage.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Migrations.Internal
namespace Microsoft.EntityFrameworkCore.Migrations.Internal
{
public class NpgsqlHistoryRepository : HistoryRepository
{
......
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Migrations.Internal
namespace Microsoft.EntityFrameworkCore.Migrations.Internal
{
public class NpgsqlMigrationsAnnotationProvider : MigrationsAnnotationProvider
{
......
......@@ -4,16 +4,14 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Internal;
using Microsoft.Data.Entity.Migrations.Operations;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Storage.Internal;
using Microsoft.Data.Entity.Update;
using Microsoft.Data.Entity.Utilities;
namespace Microsoft.Data.Entity.Migrations
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
namespace Microsoft.EntityFrameworkCore.Migrations
{
public class NpgsqlMigrationsSqlGenerator : MigrationsSqlGenerator
{
......
......@@ -3,7 +3,7 @@
using JetBrains.Annotations;
namespace Microsoft.Data.Entity.Migrations.Operations
namespace Microsoft.EntityFrameworkCore.Migrations.Operations
{
public class NpgsqlCreateDatabaseOperation : MigrationOperation
{
......
......@@ -3,7 +3,7 @@
using JetBrains.Annotations;
namespace Microsoft.Data.Entity.Migrations.Operations
namespace Microsoft.EntityFrameworkCore.Migrations.Operations
{
public class NpgsqlDropDatabaseOperation : MigrationOperation
{
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL</RootNamespace>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\Npgsql.snk</AssemblyOriginatorKeyFile>
......@@ -36,78 +36,10 @@
<DocumentationFile>bin\Release\Npgsql.EntityFrameworkCore.PostgreSQL.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\EntityFramework.Core.7.0.0-rc2-16583\lib\net451\EntityFramework.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.Relational, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\EntityFramework.Relational.7.0.0-rc2-16583\lib\net451\EntityFramework.Relational.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Caching.Abstractions.1.0.0-rc2-15948\lib\net451\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Caching.Memory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Caching.Memory.1.0.0-rc2-15948\lib\net451\Microsoft.Extensions.Caching.Memory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Binder.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.1.0.0-rc2-15888\lib\net451\Microsoft.Extensions.DependencyInjection.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0-rc2-15888\lib\net451\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.1.0.0-rc2-15926\lib\net451\Microsoft.Extensions.Logging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0-rc2-15926\lib\net451\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.OptionsModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.OptionsModel.1.0.0-rc2-15904\lib\net451\Microsoft.Extensions.OptionsModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.1.0.0-rc2-15937\lib\net451\Microsoft.Extensions.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Remotion.Linq, Version=2.0.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
<HintPath>..\..\packages\Remotion.Linq.2.0.1\lib\net45\Remotion.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.0.0-rc2-23616\lib\dotnet5.2\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -117,13 +49,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\Check.cs">
<Link>Check.cs</Link>
</Compile>
<Compile Include="Extensions\NpgsqlEntityTypeBuilderExtensions.cs" />
<Compile Include="Infrastructure\NpgsqlDbContextOptionsBuilder.cs" />
<Compile Include="Extensions\NpgsqlDbContextOptionsExtensions.cs" />
<Compile Include="Extensions\NpgsqlEntityFrameworkServicesBuilderExtensions.cs" />
<Compile Include="Metadata\INpgsqlPropertyAnnotations.cs" />
<Compile Include="Extensions\NpgsqlServiceCollectionExtensions.cs" />
<Compile Include="Metadata\Internal\NpgsqlAnnotationNames.cs" />
<Compile Include="Metadata\Internal\NpgsqlFullAnnotationNames.cs" />
<Compile Include="Metadata\Internal\NpgsqlInternalMetadataBuilderExtensions.cs" />
<Compile Include="Metadata\INpgsqlIndexAnnotations.cs" />
<Compile Include="Metadata\NpgsqlIndexAnnotations.cs" />
<Compile Include="Metadata\NpgsqlAnnotationProvider.cs" />
<Compile Include="Migrations\Operations\NpgsqlCreateDatabaseOperation.cs" />
......@@ -139,8 +75,8 @@
<Compile Include="Storage\Internal\NpgsqlDatabaseCreator.cs" />
<Compile Include="Storage\Internal\NpgsqlDatabaseProviderServices.cs" />
<Compile Include="Extensions\NpgsqlMetadataExtensions.cs" />
<Compile Include="Internal\NpgsqlModelSource.cs" />
<Compile Include="Internal\NpgsqlOptionsExtension.cs" />
<Compile Include="Infrastructure\Internal\NpgsqlModelSource.cs" />
<Compile Include="Infrastructure\Internal\NpgsqlOptionsExtension.cs" />
<Compile Include="Storage\Internal\NpgsqlTypeMapper.cs" />
<Compile Include="Storage\Internal\NpgsqlTypeMapping.cs" />
<Compile Include="Update\Internal\NpgsqlUpdateSqlGenerator.cs" />
......@@ -171,18 +107,11 @@
<Compile Include="Update\Internal\NpgsqlModificationCommandBatch.cs" />
<Compile Include="Update\Internal\NpgsqlModificationCommandBatchFactory.cs" />
<Compile Include="Utilities\AsyncEnumerableExtensions.cs" />
<Compile Include="Utilities\Check.cs" />
<Compile Include="Utilities\EnumerableExtensions.cs" />
<Compile Include="Utilities\SharedTypeExtensions.cs" />
<Compile Include="Utilities\StringBuilderExtensions.cs" />
<Compile Include="ValueGeneration\Internal\NpgsqlValueGeneratorCache.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Npgsql\Npgsql.csproj">
<Project>{9d13b739-62b1-4190-b386-7a9547304eb3}</Project>
<Name>Npgsql</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
......@@ -196,4 +125,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
\ No newline at end of file
......@@ -3,10 +3,11 @@
using System.Reflection;
using System.Resources;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure;
[assembly: AssemblyTitle("EntityFramework7.Npgsql")]
[assembly: AssemblyDescription("PostgreSQL provider for Entity Framework 7")]
[assembly: AssemblyTitle("Npgsql.EntityFrameworkCore.PostgreSQL")]
[assembly: AssemblyDescription("PostgreSQL provider for Entity Framework Core")]
[assembly: DesignTimeProviderServices(
fullyQualifiedTypeName: "Microsoft.Data.Entity.Scaffolding.NpgsqlDesignTimeServices, EntityFramework7.Npgsql.Design",
packageName: "EntityFramework7.Npgsql.Design")]
typeName: "Microsoft.EntityFrameworkCore.Scaffolding.NpgsqlDesignTimeServices",
assemblyName: "Npgsql.EntityFrameworkCore.PostgreSQL.Design",
packageName: "Npgsql.EntityFrameworkCore.PostgreSQL.Design")]
......@@ -3,8 +3,7 @@
using System.Collections.Generic;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlCompositeMemberTranslator : RelationalCompositeMemberTranslator
{
......
......@@ -4,8 +4,7 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlCompositeMethodCallTranslator : RelationalCompositeMethodCallTranslator
{
......
......@@ -4,11 +4,10 @@
using System;
using System.Linq.Expressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.Data.Entity.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlDateTimeNowTranslator : IMemberTranslator
{
......
......@@ -3,8 +3,7 @@
using System;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathAbsTranslator : MultipleOverloadStaticMethodCallTranslator
{
......
......@@ -3,8 +3,7 @@
using System;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathCeilingTranslator : MultipleOverloadStaticMethodCallTranslator
{
......
......@@ -3,8 +3,7 @@
using System;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathFloorTranslator : MultipleOverloadStaticMethodCallTranslator
{
......
......@@ -3,8 +3,7 @@
using System;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathPowerTranslator : SingleOverloadStaticMethodCallTranslator
{
......
......@@ -7,10 +7,9 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathRoundTranslator : IMethodCallTranslator
{
......
......@@ -7,10 +7,9 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlMathTruncateTranslator : IMethodCallTranslator
{
......
......@@ -6,11 +6,9 @@
using System.Reflection;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.Data.Entity.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
/// <summary>
/// Translates Regex.IsMatch calls into PostgreSQL regex expressions for database-side processing.
......
......@@ -3,10 +3,9 @@
using System.Linq.Expressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlStringLengthTranslator : IMemberTranslator
{
......
......@@ -5,10 +5,9 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlStringReplaceTranslator : IMethodCallTranslator
{
......
......@@ -5,10 +5,9 @@
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlStringSubstringTranslator : IMethodCallTranslator
{
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlStringToLowerTranslator : ParameterlessInstanceMethodCallTranslator
{
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.ExpressionTranslators.Internal
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal
{
public class NpgsqlStringToUpperTranslator : ParameterlessInstanceMethodCallTranslator
{
......
using System;
using System.Linq.Expressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Sql.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Query.Sql.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Expressions.Internal
namespace Microsoft.EntityFrameworkCore.Query.Expressions.Internal
{
public class AtTimeZoneExpression : Expression
{
......
......@@ -5,12 +5,10 @@
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Sql;
using Microsoft.Data.Entity.Query.Sql.Internal;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Query.Sql.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Expressions.Internal
namespace Microsoft.EntityFrameworkCore.Query.Expressions.Internal
{
public class RegexMatchExpression : Expression
{
......
using System;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Query.ExpressionVisitors;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Internal
namespace Microsoft.EntityFrameworkCore.Query.Internal
{
public class NpgsqlQueryCompilationContext : RelationalQueryCompilationContext
{
......
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Query.ExpressionVisitors;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors;
using Microsoft.EntityFrameworkCore.Utilities;
using Remotion.Linq.Parsing.Structure.NodeTypeProviders;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Internal
namespace Microsoft.EntityFrameworkCore.Query.Internal
{
public class NpgsqlQueryCompilationContextFactory : RelationalQueryCompilationContextFactory
{
......@@ -16,14 +16,14 @@ public class NpgsqlQueryCompilationContextFactory : RelationalQueryCompilationCo
[NotNull] IEntityQueryModelVisitorFactory entityQueryModelVisitorFactory,
[NotNull] IRequiresMaterializationExpressionVisitorFactory requiresMaterializationExpressionVisitorFactory,
[NotNull] MethodInfoBasedNodeTypeRegistry methodInfoBasedNodeTypeRegistry,
[NotNull] DbContext context)
[NotNull] ICurrentDbContext currentContext)
: base(
Check.NotNull(model, nameof(model)),
Check.NotNull(logger, nameof(logger)),
Check.NotNull(entityQueryModelVisitorFactory, nameof(entityQueryModelVisitorFactory)),
Check.NotNull(requiresMaterializationExpressionVisitorFactory, nameof(requiresMaterializationExpressionVisitorFactory)),
Check.NotNull(methodInfoBasedNodeTypeRegistry, nameof(methodInfoBasedNodeTypeRegistry)),
Check.NotNull(context, nameof(context)))
Check.NotNull(currentContext, nameof(currentContext)))
{
}
......
......@@ -2,16 +2,19 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.Data.Entity.Query.Expressions.Internal;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Sql.Internal
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
using Remotion.Linq.Parsing;
namespace Microsoft.EntityFrameworkCore.Query.Sql.Internal
{
public class NpgsqlQuerySqlGenerator : DefaultQuerySqlGenerator
{
......
......@@ -2,12 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity.Query.Expressions;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Query.Expressions;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Query.Sql.Internal
namespace Microsoft.EntityFrameworkCore.Query.Sql.Internal
{
public class NpgsqlQuerySqlGeneratorFactory : QuerySqlGeneratorFactoryBase
{
......
......@@ -5,14 +5,13 @@
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations.Operations;
using Microsoft.Data.Entity.Utilities;
using Microsoft.Data.Entity.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Utilities;
using Npgsql;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlDatabaseCreator : RelationalDatabaseCreator
{
......
......@@ -4,25 +4,25 @@
using System;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.Conventions.Internal;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Internal;
using Microsoft.Data.Entity.Query;
using Microsoft.Data.Entity.Query.ExpressionTranslators;
using Microsoft.Data.Entity.Query.ExpressionTranslators.Internal;
using Microsoft.Data.Entity.Query.Internal;
using Microsoft.Data.Entity.Query.Sql;
using Microsoft.Data.Entity.Query.Sql.Internal;
using Microsoft.Data.Entity.Update;
using Microsoft.Data.Entity.Update.Internal;
using Microsoft.Data.Entity.ValueGeneration;
using Microsoft.Data.Entity.ValueGeneration.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.Sql;
using Microsoft.EntityFrameworkCore.Query.Sql.Internal;
using Microsoft.EntityFrameworkCore.Update;
using Microsoft.EntityFrameworkCore.Update.Internal;
using Microsoft.EntityFrameworkCore.ValueGeneration;
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlDatabaseProviderServices : RelationalDatabaseProviderServices
{
......
......@@ -3,13 +3,11 @@
using System.Data.Common;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Logging;
using Npgsql;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlRelationalConnection : RelationalConnection
{
......
......@@ -3,20 +3,17 @@
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Utilities;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlSqlGenerationHelper : RelationalSqlGenerationHelper
{
public override string EscapeIdentifier([NotNull] string identifier)
public override string EscapeIdentifier(string identifier)
=> Check.NotEmpty(identifier, nameof(identifier)).Replace("\"", "\"\"");
public override string DelimitIdentifier([NotNull] string identifier)
public override string DelimitIdentifier(string identifier)
=> $"\"{EscapeIdentifier(Check.NotEmpty(identifier, nameof(identifier)))}\"";
protected override string GenerateLiteralValue(byte[] literal)
......
......@@ -3,14 +3,14 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using Microsoft.Data.Entity.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Npgsql;
using Npgsql.TypeHandlers;
// ReSharper disable once CheckNamespace
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
// TODO: BIT(1) vs. BIT(N)
// TODO: Enums - https://github.com/aspnet/EntityFramework/issues/3620
......
......@@ -3,14 +3,11 @@
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Storage;
using Npgsql;
using NpgsqlTypes;
namespace Microsoft.Data.Entity.Storage.Internal
namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlTypeMapping : RelationalTypeMapping
{
......
......@@ -3,17 +3,16 @@
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Npgsql;
namespace Microsoft.Data.Entity.Update.Internal
namespace Microsoft.EntityFrameworkCore.Update.Internal
{
using RelationalStrings = Microsoft.Data.Entity.Internal.RelationalStrings;
/// <remarks>
/// The usual ModificationCommandBatch implementation is <see cref="AffectedCountModificationCommandBatch"/>,
/// which relies on <see cref="SqlGenerator.AppendSelectAffectedCountCommand"/> to fetch the number of
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
namespace Microsoft.Data.Entity.Update.Internal
namespace Microsoft.EntityFrameworkCore.Update.Internal
{
public class NpgsqlModificationCommandBatchFactory : IModificationCommandBatchFactory
{
......
......@@ -3,13 +3,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Storage;
using Microsoft.Data.Entity.Utilities;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
namespace Microsoft.Data.Entity.Update.Internal
namespace Microsoft.EntityFrameworkCore.Update.Internal
{
public class NpgsqlUpdateSqlGenerator : UpdateSqlGenerator
{
......
namespace Microsoft.Data.Entity.ValueGeneration.Internal
namespace Microsoft.EntityFrameworkCore.ValueGeneration.Internal
{
public class NpgsqlValueGeneratorCache : ValueGeneratorCache
{
......
......@@ -3,7 +3,7 @@
"authors": [
"Shay Rojansky"
],
"description" : "PostgreSQL provider for Entity Framework 7",
"description" : "PostgreSQL provider for Entity Framework Core",
"iconUrl": "http://www.npgsql.org/img/postgresql.gif",
"repository": {
"type": "git",
......@@ -11,26 +11,22 @@
},
"compile": "../Shared/*.cs",
"compilationOptions": {
"keyFile": "../../Npgsql.snk"
"keyFile": "../../Npgsql.snk",
"warningsAsErrors": true
},
"dependencies" : {
"EntityFramework.Core": "7.0.0-rc2-*",
"EntityFramework.Relational": "7.0.0-rc2-*",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-*",
"Npgsql": "3.1.0-*"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Collections": { "version": "4.0.0.0", "type": "build" },
"System.Reflection": { "version": "4.0.0.0", "type": "build" },
"System.Diagnostics.Contracts": { "version": "4.0.0.0", "type": "build" },
"System.Linq.Expressions": { "version": "4.0.0.0", "type": "build" },
"System.Runtime": { "version": "4.0.0.0", "type": "build" }
}
},
"net451": {},
"netstandard13": {
"imports": [
"portable-net452+win81"
],
"dependencies": {
}
}
......
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
......@@ -7,9 +7,9 @@
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Internal;
using Microsoft.EntityFrameworkCore.Internal;
namespace Microsoft.Data.Entity.Utilities
namespace Microsoft.EntityFrameworkCore.Utilities
{
[DebuggerStepThrough]
internal static class Check
......@@ -85,7 +85,7 @@ public static string NotEmpty(string value, [InvokerParameterName] [NotNull] str
public static string NullButNotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
{
if (!ReferenceEquals(value, null)
&& value.Length == 0)
&& (value.Length == 0))
{
NotEmpty(parameterName, nameof(parameterName));
......@@ -110,26 +110,13 @@ public static IReadOnlyList<T> HasNoNulls<T>(IReadOnlyList<T> value, [InvokerPar
return value;
}
public static T IsDefined<T>(T value, [InvokerParameterName] [NotNull] string parameterName)
where T : struct
{
if (!Enum.IsDefined(typeof(T), value))
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.InvalidEnumValue(parameterName, typeof(T)));
}
return value;
}
public static Type ValidEntityType(Type value, [InvokerParameterName] [NotNull] string parameterName)
{
if (!value.GetTypeInfo().IsClass)
{
NotEmpty(parameterName, nameof(parameterName));
throw new ArgumentException(CoreStrings.InvalidEntityType(parameterName, value));
throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
}
return value;
......
......@@ -183,7 +183,7 @@
<Compile Include="NpgsqlDatabaseModelFactoryTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReverseEngineering\NpgsqlE2ETests.cs" />
<Compile Include="ReverseEngineering\NpsqlE2EFixture.cs" />
<Compile Include="ReverseEngineering\NpgsqlE2EFixture.cs" />
<Compile Include="Utilities\Util.cs" />
</ItemGroup>
<ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Scaffolding;
using Microsoft.Data.Entity.Scaffolding.Metadata;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using EntityFramework7.Npgsql.FunctionalTests;
using Microsoft.Extensions.Logging;
namespace EntityFramework7.Npgsql.Design.FunctionalTests
using Microsoft.EntityFrameworkCore.FunctionalTests.TestUtilities.Xunit;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests
{
public class NpgsqlDatabaseModelFactoryTest : IClassFixture<NpgsqlDatabaseModelFixture>
{
......@@ -48,8 +52,8 @@ public void It_reads_foreign_keys()
Assert.Equal("mountains", fk.Table.Name);
Assert.Equal("public", fk.PrincipalTable.SchemaName);
Assert.Equal("ranges", fk.PrincipalTable.Name);
Assert.Equal("range_id", fk.Columns.Single().Name);
Assert.Equal("id", fk.PrincipalColumns.Single().Name);
Assert.Equal("range_id", fk.Columns.Single().Column.Name);
Assert.Equal("id", fk.Columns.Single().PrincipalColumn.Name);
Assert.Equal(ReferentialAction.Cascade, fk.OnDelete);
}
......@@ -67,8 +71,8 @@ public void It_reads_composite_foreign_keys()
Assert.Equal("mountains1", fk.Table.Name);
Assert.Equal("public", fk.PrincipalTable.SchemaName);
Assert.Equal("ranges1", fk.PrincipalTable.Name);
Assert.Equal(new[] { "range_id", "range_alt_id" }, fk.Columns.Select(c => c.Name).ToArray());
Assert.Equal(new[] { "id", "alt_id" }, fk.PrincipalColumns.Select(c => c.Name).ToArray());
Assert.Equal(new[] { "range_id", "range_alt_id" }, fk.Columns.Select(c => c.Column.Name).ToArray());
Assert.Equal(new[] { "id", "alt_id" }, fk.Columns.Select(c => c.PrincipalColumn.Name).ToArray());
Assert.Equal(ReferentialAction.NoAction, fk.OnDelete);
}
......@@ -91,13 +95,13 @@ public void It_reads_indexes()
unique =>
{
Assert.True(unique.IsUnique);
Assert.Equal("name", unique.Columns.Single().Name);
Assert.Equal("name", unique.IndexColumns.Single().Column.Name);
},
composite =>
{
Assert.Equal("IX_name_location", composite.Name);
Assert.False(composite.IsUnique);
Assert.Equal(new List<string> { "name", "location" }, composite.Columns.Select(c => c.Name).ToList());
Assert.Equal(new List<string> { "name", "location" }, composite.IndexColumns.Select(c => c.Column.Name).ToList());
});
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntityFramework7.Npgsql.FunctionalTests;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Microsoft.Extensions.Logging;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.Design.FunctionalTests.ReverseEngineering
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.ReverseEngineering
{
public class NpgsqlE2EFixture
{
......
// With RC2 these tests fail apparently because CompilationServices.Default is null
// (see https://github.com/aspnet/dnx/issues/3248). Follow EF7 on this.
#if NET46
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Reflection;
using EntityFramework7.Npgsql.FunctionalTests;
using Microsoft.CodeAnalysis;
using Microsoft.Data.Entity.FunctionalTests.TestUtilities.Xunit;
using Microsoft.Data.Entity.Relational.Design.FunctionalTests.ReverseEngineering;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Xunit.Abstractions;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Scaffolding;
using Microsoft.Data.Entity.Scaffolding.Internal;
namespace EntityFramework7.Npgsql.Design.FunctionalTests.ReverseEngineering
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore.FunctionalTests.TestUtilities.Xunit;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Relational.Design.FunctionalTests.ReverseEngineering;
using Microsoft.EntityFrameworkCore.Relational.Design.FunctionalTests.TestUtilities;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.EntityFrameworkCore.Scaffolding.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests.ReverseEngineering
{
public class NpgsqlE2ETests : E2ETestBase, IClassFixture<NpgsqlE2EFixture>
{
protected override string ProviderName => "EntityFramework7.Npgsql.Design";
protected override string ProviderName => "Npgsql.EntityFrameworkCore.PostgreSQL.Design";
protected override void ConfigureDesignTimeServices(IServiceCollection services)
{
new NpgsqlDesignTimeServices().ConfigureDesignTimeServices(services);
}
protected override IServiceCollection ConfigureDesignTimeServices(IServiceCollection services)
=> new NpgsqlDesignTimeServices().ConfigureDesignTimeServices(services);
public virtual string TestNamespace => "E2ETest.Namespace";
public virtual string TestProjectDir => Path.Combine("E2ETest", "Output");
......@@ -59,32 +53,6 @@ public NpgsqlE2ETests(NpgsqlE2EFixture fixture, ITestOutputHelper output)
{
}
protected override E2ECompiler GetCompiler() => new E2ECompiler
{
NamedReferences =
{
"EntityFramework.Core",
"EntityFramework.Relational",
"EntityFramework7.Npgsql",
#if DNXCORE50 || NETCORE50
"System.Data.Common",
"System.Linq.Expressions",
"System.Reflection",
"System.ComponentModel.Annotations",
#else
},
References =
{
MetadataReference.CreateFromFile(
Assembly.Load(new AssemblyName(
"System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")).Location),
MetadataReference.CreateFromFile(
Assembly.Load(new AssemblyName(
"System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")).Location),
#endif
}
};
string _connectionString = NpgsqlTestStore.CreateConnectionString("NpgsqlReverseEngineerTestE2E");
private static readonly List<string> _expectedEntityTypeFiles = new List<string>
......@@ -252,6 +220,27 @@ MINVALUE 0
AssertCompile(actualFileSet);
}
}
protected override ICollection<BuildReference> References { get; } = new List<BuildReference>
{
#if NETSTANDARDAPP1_5
BuildReference.ByName("System.Collections"),
BuildReference.ByName("System.Data.Common"),
BuildReference.ByName("System.Linq.Expressions"),
BuildReference.ByName("System.Reflection"),
BuildReference.ByName("System.ComponentModel.Annotations"),
BuildReference.ByName("Npgsql.EntityFrameworkCore.PostgreSQL", depContextAssembly: typeof(NpgsqlE2ETests).GetTypeInfo().Assembly),
#else
BuildReference.ByName("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
BuildReference.ByName("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
BuildReference.ByName("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
BuildReference.ByName("System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"),
BuildReference.ByName("Npgsql.EntityFrameworkCore.PostgreSQL"),
#endif
BuildReference.ByName("Microsoft.EntityFrameworkCore"),
BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"),
BuildReference.ByName("Microsoft.Extensions.Caching.Abstractions"),
BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions")
};
}
}
#endif
{
"dependencies": {
"EntityFramework.Relational.FunctionalTests": "7.0.0-rc2-16583",
"EntityFramework.Relational.Design.FunctionalTests": "7.0.0-rc2-16583",
"EntityFramework7.Npgsql.Design": "3.1.0-*",
"EntityFramework7.Npgsql": "3.1.0-*",
"EntityFramework7.Npgsql.FunctionalTests": "1.0.0"
},
"commands": {
"test": "xunit.runner.dnx"
"Microsoft.EntityFrameworkCore.Relational.FunctionalTests": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational.Design.FunctionalTests": "1.0.0-rc2-*",
"Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.0.0-*",
"Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests": "1.0.0-*"
},
"testRunner": "xunit",
"frameworks": {
"net46": {
"net451": {
"frameworkAssemblies": {
"System.Threading.Tasks": { "version": "4.0.0.0", "type": "build" }
}
},
"dnx452": {
"frameworkAssemblies": {
"System.Threading.Tasks": "4.0.0.0"
},
"dependencies": {
"xunit.runner.dnx": "2.1.0-rc1-*"
}
},
"dnxcore50": {
"dependencies": {
"xunit.runner.dnx": "2.1.0-rc1-*"
}
}
}
}
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class AsNoTrackingNpgsqlTest : AsNoTrackingTestBase<NorthwindQueryNpgsqlFixture>
{
......
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class AsTrackingSqlServerTest : AsTrackingTestBase<NorthwindQueryNpgsqlFixture>
public class AsTrackingNpgsqlTest : AsTrackingTestBase<NorthwindQueryNpgsqlFixture>
{
public AsTrackingSqlServerTest(NorthwindQueryNpgsqlFixture fixture)
public AsTrackingNpgsqlTest(NorthwindQueryNpgsqlFixture fixture)
: base(fixture)
{
}
......
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class AsyncFromSqlQueryNpgsqlTest : AsyncFromSqlQueryTestBase<NorthwindQueryNpgsqlFixture>
{
......
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Xunit;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class AsyncQueryNpgsqlTest : AsyncQueryTestBase<NorthwindQueryNpgsqlFixture>
{
......@@ -18,27 +17,18 @@ public AsyncQueryNpgsqlTest(NorthwindQueryNpgsqlFixture fixture) : base(fixture)
#region Skipped tests
[Fact(Skip = "Test commented out in EF7 (SqlServer/Sqlite)")]
[Fact(Skip = "Test commented out in EF7 (Npgsql/Sqlite)")]
public override Task Projection_when_arithmetic_expressions() { return null; }
[Fact(Skip = "Test commented out in EF7 (SqlServer/Sqlite)")]
[Fact(Skip = "Test commented out in EF7 (Npgsql/Sqlite)")]
public override Task Projection_when_arithmetic_mixed() { return null; }
[Fact(Skip = "Test commented out in EF7 (SqlServer/Sqlite)")]
[Fact(Skip = "Test commented out in EF7 (Npgsql/Sqlite)")]
public override Task Projection_when_arithmetic_mixed_subqueries() { return null; }
[Fact(Skip = "https://github.com/aspnet/EntityFramework/issues/3036")]
public override Task GroupJoin_customers_orders_count() { return null; }
#endregion
[Fact]
public async Task Completes_When_No_Results()
{
using (var db = _fixture.CreateContext())
{
await db.Customers.Where(r => r.Address == "notindatabase").FirstOrDefaultAsync();
}
}
}
}
......@@ -3,13 +3,14 @@
using System;
using System.Linq;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class BatchingTest : IDisposable
{
......@@ -41,16 +42,22 @@ public void Batches_are_divided_correctly_with_two_inserted_columns()
private class BloggingContext : DbContext
{
public BloggingContext(IServiceProvider serviceProvider, DbContextOptions options)
: base(serviceProvider, options)
: base(new DbContextOptionsBuilder(options).UseInternalServiceProvider(serviceProvider).Options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().Property(e => e.Id).ValueGeneratedNever();
modelBuilder.Entity<Blog>(b =>
{
//b.Property(e => e.Id).HasDefaultValueSql("NEWID()");
//b.Property(e => e.Version).IsConcurrencyToken().ValueGeneratedOnAddOrUpdate();
// TODO: Bring this up to date...
});
}
public DbSet<Blog> Blogs { get; set; }
public DbSet<Owner> Owners { get; set; }
}
public class Blog
......@@ -60,6 +67,11 @@ public class Blog
public string Description { get; set; }
}
public class Owner
{
public int Id { get; set; }
}
private readonly NpgsqlTestStore _testStore;
private readonly IServiceProvider _serviceProvider;
......@@ -67,9 +79,7 @@ public BatchingTest()
{
_testStore = NpgsqlTestStore.CreateScratch();
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.BuildServiceProvider();
}
......
......@@ -5,19 +5,19 @@
using System.Linq;
using System.Net.NetworkInformation;
using System.Reflection;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Npgsql;
using NpgsqlTypes;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class BuiltInDataTypesNpgsqlFixture : BuiltInDataTypesFixtureBase
{
private readonly IServiceProvider _serviceProvider;
private readonly DbContextOptions _options;
private readonly NpgsqlTestStore _testStore;
......@@ -29,19 +29,17 @@ public BuiltInDataTypesNpgsqlFixture()
NpgsqlConnection.MapCompositeGlobally<SomeComposite>("somecomposite");
((NpgsqlConnection)_testStore.Connection).ReloadTypes();
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
var serviceProvider = new ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.BuildServiceProvider();
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(_testStore.Connection);
_options = new DbContextOptionsBuilder()
.UseNpgsql(_testStore.Connection)
.UseInternalServiceProvider(serviceProvider)
.Options;
_options = optionsBuilder.Options;
using (var context = new DbContext(_serviceProvider, _options))
using (var context = new DbContext(_options))
{
context.Database.EnsureCreated();
}
......@@ -49,7 +47,7 @@ public BuiltInDataTypesNpgsqlFixture()
public override DbContext CreateContext()
{
var context = new DbContext(_serviceProvider, _options);
var context = new DbContext(_options);
context.Database.UseTransaction(_testStore.Transaction);
return context;
}
......@@ -284,5 +282,7 @@ public override bool Equals(object obj)
var o = obj as SomeComposite;
return o != null && o.SomeNumber == SomeNumber && o.SomeText == o.SomeText;
}
public override int GetHashCode() => SomeNumber.GetHashCode() ^ SomeText.GetHashCode();
}
}
using System;
using System.Linq;
using System.Net.NetworkInformation;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using NpgsqlTypes;
using Xunit;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class BuiltInDataTypesNpgsqlTest : BuiltInDataTypesTestBase<BuiltInDataTypesNpgsqlFixture>
{
......@@ -391,6 +390,6 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null()
}
}
// TODO: Other tests from SqlServerBuiltInDataTypesSqlServerTest?
// TODO: Other tests from NpgsqlBuiltInDataTypesNpgsqlTest?
}
}
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Xunit;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class ChangeTrackingNpgsqlTest : ChangeTrackingTestBase<NorthwindQueryNpgsqlFixture>
{
......
......@@ -3,13 +3,14 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.FunctionalTests.TestModels.ComplexNavigationsModel;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.ComplexNavigationsModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class ComplexNavigationsQueryNpgsqlFixture : ComplexNavigationsQueryRelationalFixture<NpgsqlTestStore>
{
......@@ -22,23 +23,20 @@ public class ComplexNavigationsQueryNpgsqlFixture : ComplexNavigationsQueryRelat
public ComplexNavigationsQueryNpgsqlFixture()
{
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.AddSingleton<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider();
}
public override NpgsqlTestStore CreateTestStore() =>
NpgsqlTestStore.GetOrCreateShared(
DatabaseName,
() =>
NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(_connectionString);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(_connectionString)
.UseInternalServiceProvider(_serviceProvider);
using (var context = new ComplexNavigationsContext(_serviceProvider, optionsBuilder.Options))
using (var context = new ComplexNavigationsContext(optionsBuilder.Options))
{
// TODO: Delete DB if model changed
context.Database.EnsureDeleted();
......@@ -53,10 +51,14 @@ public ComplexNavigationsQueryNpgsqlFixture()
public override ComplexNavigationsContext CreateContext(NpgsqlTestStore testStore)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(testStore.Connection);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(testStore.Connection)
.UseInternalServiceProvider(_serviceProvider);
var context = new ComplexNavigationsContext(optionsBuilder.Options);
context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var context = new ComplexNavigationsContext(_serviceProvider, optionsBuilder.Options);
context.Database.UseTransaction(testStore.Transaction);
return context;
......
......@@ -3,10 +3,11 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.FunctionalTests;
using Xunit;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class ComplexNavigationsQueryNpgsqlTest : ComplexNavigationsQueryTestBase<NpgsqlTestStore, ComplexNavigationsQueryNpgsqlFixture>
{
......
......@@ -3,29 +3,26 @@
using System;
using System.Linq;
using EntityFramework7.Npgsql.FunctionalTests.TestModels;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Internal;
using Microsoft.Data.Entity.Storage.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.TestModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.Extensions.DependencyInjection;
using Npgsql;
using Xunit;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class ConnectionSpecificationTest
{
[Fact]
public void Can_specify_connection_string_in_OnConfiguring()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql()
.AddDbContext<StringInOnConfiguringContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddDbContext<StringInOnConfiguringContext>()
.BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -59,14 +56,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
[Fact]
public void Can_specify_connection_in_OnConfiguring()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddScoped(p => new NpgsqlConnection(NpgsqlNorthwindContext.ConnectionString))
.AddEntityFramework()
.AddNpgsql()
.AddDbContext<ConnectionInOnConfiguringContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddScoped(p => new NpgsqlConnection(NpgsqlNorthwindContext.ConnectionString))
.AddDbContext<ConnectionInOnConfiguringContext>().BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -121,13 +114,9 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
[Fact]
public void Throws_if_no_connection_found_in_config_without_UseNpgsql()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql()
.AddDbContext<NoUseNpgsqlContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddDbContext<NoUseNpgsqlContext>().BuildServiceProvider();
using (var context = serviceProvider.GetRequiredService<NoUseNpgsqlContext>())
{
......@@ -140,13 +129,9 @@ public void Throws_if_no_connection_found_in_config_without_UseNpgsql()
[Fact]
public void Throws_if_no_config_without_UseNpgsql()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql()
.AddDbContext<NoUseNpgsqlContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddDbContext<NoUseNpgsqlContext>().BuildServiceProvider();
using (var context = serviceProvider.GetRequiredService<NoUseNpgsqlContext>())
{
......@@ -163,15 +148,11 @@ private class NoUseNpgsqlContext : NorthwindContextBase
[Fact]
public void Can_select_appropriate_provider_when_multiple_registered()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddScoped<SomeService>()
.AddEntityFramework()
.AddNpgsql()
.AddInMemoryDatabase()
.AddDbContext<MultipleProvidersContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddScoped<SomeService>()
.AddDbContext<MultipleProvidersContext>()
.BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -268,14 +249,11 @@ public SomeService(MultipleProvidersContext context)
[Fact]
public void Can_depend_on_DbContextOptions()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddScoped(p => new NpgsqlConnection(NpgsqlNorthwindContext.ConnectionString))
.AddEntityFramework()
.AddNpgsql()
.AddDbContext<OptionsContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddScoped(p => new NpgsqlConnection(NpgsqlNorthwindContext.ConnectionString))
.AddDbContext<OptionsContext>()
.BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -331,15 +309,10 @@ public override void Dispose()
[Fact]
public void Can_register_multiple_context_types()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql()
.AddInMemoryDatabase()
var serviceProvider = new ServiceCollection()
.AddDbContext<MultipleContext1>()
.AddDbContext<MultipleContext2>();
var serviceProvider = serviceCollection.BuildServiceProvider();
.AddDbContext<MultipleContext2>()
.BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -415,14 +388,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
[Fact]
public void Can_depend_on_non_generic_options_when_only_one_context()
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql()
.AddInMemoryDatabase()
.AddDbContext<NonGenericOptionsContext>();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider
= new ServiceCollection()
.AddDbContext<NonGenericOptionsContext>()
.BuildServiceProvider();
using (NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -504,11 +473,6 @@ public void Can_specify_connection_in_OnConfiguring_and_create_master_connection
{
conn.Open();
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql();
using (NpgsqlNorthwindContext.GetSharedStore())
{
using (var context = new ConnectionInOnConfiguringContext(conn))
......
......@@ -3,12 +3,13 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class DataAnnotationNpgsqlFixture : DataAnnotationFixtureBase<NpgsqlTestStore>
{
......@@ -21,9 +22,7 @@ public class DataAnnotationNpgsqlFixture : DataAnnotationFixtureBase<NpgsqlTestS
public DataAnnotationNpgsqlFixture()
{
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.AddSingleton<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider();
......@@ -33,10 +32,11 @@ public override NpgsqlTestStore CreateTestStore()
{
return NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(_connectionString);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(_connectionString)
.UseInternalServiceProvider(_serviceProvider);
using (var context = new DataAnnotationContext(_serviceProvider, optionsBuilder.Options))
using (var context = new DataAnnotationContext(optionsBuilder.Options))
{
// TODO: Delete DB if model changed
context.Database.EnsureDeleted();
......@@ -52,10 +52,12 @@ public override NpgsqlTestStore CreateTestStore()
public override DataAnnotationContext CreateContext(NpgsqlTestStore testStore)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.EnableSensitiveDataLogging().UseNpgsql(testStore.Connection);
var optionsBuilder = new DbContextOptionsBuilder()
.EnableSensitiveDataLogging()
.UseNpgsql(testStore.Connection)
.UseInternalServiceProvider(_serviceProvider);
var context = new DataAnnotationContext(_serviceProvider, optionsBuilder.Options);
var context = new DataAnnotationContext(optionsBuilder.Options);
context.Database.UseTransaction(testStore.Transaction);
return context;
}
......
......@@ -3,11 +3,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.Metadata;
using Xunit;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.Metadata;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class DataAnnotationNpgsqlTest : DataAnnotationTestBase<NpgsqlTestStore, DataAnnotationNpgsqlFixture>
{
......
......@@ -3,19 +3,18 @@
using System;
using System.Linq;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.Extensions.DependencyInjection;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class DefaultValuesTest : IDisposable
{
private readonly IServiceProvider _serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.BuildServiceProvider();
[Fact]
......@@ -52,28 +51,27 @@ public void Dispose()
private class ChipsContext : DbContext
{
private readonly IServiceProvider _serviceProvider;
private readonly string _databaseName;
public ChipsContext(IServiceProvider serviceProvider, string databaseName)
: base(serviceProvider)
{
_serviceProvider = serviceProvider;
_databaseName = databaseName;
}
public DbSet<KettleChips> Chips { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName));
}
=> optionsBuilder
.UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName))
.UseInternalServiceProvider(_serviceProvider);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<KettleChips>()
=> modelBuilder.Entity<KettleChips>()
.Property(e => e.BestBuyDate)
.ValueGeneratedOnAdd()
.HasDefaultValue(new DateTime(2035, 9, 25));
}
}
private class KettleChips
......
......@@ -6,11 +6,11 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using EntityFramework7.Npgsql.FunctionalTests.TestModels;
using Microsoft.Data.Entity;
using Microsoft.EntityFrameworkCore;
using Npgsql;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.TestModels;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class ExistingConnectionTest
{
......@@ -29,12 +29,9 @@ public async Task Can_use_an_existing_open_connection()
private static async Task Can_use_an_existing_closed_connection_test(bool openConnection)
{
var serviceCollection = new ServiceCollection();
serviceCollection
.AddEntityFramework()
.AddNpgsql();
var serviceProvider = serviceCollection.BuildServiceProvider();
var serviceProvider = new ServiceCollection()
.AddEntityFrameworkNpgsql()
.BuildServiceProvider();
using (var store = NpgsqlNorthwindContext.GetSharedStore())
{
......@@ -60,7 +57,7 @@ private static async Task Can_use_an_existing_closed_connection_test(bool openCo
closeCount++;
}
};
#if !DNXCORE50
#if NET451
connection.Disposed += (_, __) => disposeCount++;
#endif
......@@ -89,29 +86,28 @@ private static async Task Can_use_an_existing_closed_connection_test(bool openCo
private class NorthwindContext : DbContext
{
private readonly IServiceProvider _serviceProvider;
private readonly NpgsqlConnection _connection;
public NorthwindContext(IServiceProvider serviceProvider, NpgsqlConnection connection)
: base(serviceProvider)
{
_serviceProvider = serviceProvider;
_connection = connection;
}
public DbSet<Customer> Customers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(_connection);
}
=> optionsBuilder
.UseNpgsql(_connection)
.UseInternalServiceProvider(_serviceProvider);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>(b =>
=> modelBuilder.Entity<Customer>(b =>
{
b.HasKey(c => c.CustomerID);
b.ForNpgsqlToTable("Customers");
});
}
}
private class Customer
......
......@@ -3,13 +3,14 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.FunctionalTests.TestModels.ConcurrencyModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.ConcurrencyModel;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class F1NpgsqlFixture : F1RelationalFixture<NpgsqlTestStore>
{
......@@ -22,9 +23,7 @@ public class F1NpgsqlFixture : F1RelationalFixture<NpgsqlTestStore>
public F1NpgsqlFixture()
{
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.AddSingleton<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider();
......@@ -34,10 +33,11 @@ public override NpgsqlTestStore CreateTestStore()
{
return NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(_connectionString);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(_connectionString)
.UseInternalServiceProvider(_serviceProvider);
using (var context = new F1Context(_serviceProvider, optionsBuilder.Options))
using (var context = new F1Context(optionsBuilder.Options))
{
// TODO: Delete DB if model changed
context.Database.EnsureDeleted();
......@@ -53,10 +53,11 @@ public override NpgsqlTestStore CreateTestStore()
public override F1Context CreateContext(NpgsqlTestStore testStore)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(testStore.Connection);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(testStore.Connection)
.UseInternalServiceProvider(_serviceProvider);
var context = new F1Context(_serviceProvider, optionsBuilder.Options);
var context = new F1Context(optionsBuilder.Options);
context.Database.UseTransaction(testStore.Transaction);
return context;
}
......
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Data.Entity.FunctionalTests;
using System.Data.Common;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Xunit;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class FromSqlQueryNpgsqlTest : FromSqlQueryTestBase<NorthwindQueryNpgsqlFixture>
{
......@@ -298,6 +299,13 @@ public FromSqlQueryNpgsqlTest(NorthwindQueryNpgsqlFixture fixture)
{
}
protected override DbParameter CreateDbParameter(string name, object value)
=> new NpgsqlParameter
{
ParameterName = name,
Value = value
};
private static string Sql => TestSqlLoggerFactory.Sql;
}
}
......@@ -3,13 +3,14 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Data.Entity.FunctionalTests.TestModels.GearsOfWarModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests.TestModels.GearsOfWarModel;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class GearsOfWarQueryNpgsqlFixture : GearsOfWarQueryRelationalFixture<NpgsqlTestStore>
{
......@@ -22,9 +23,7 @@ public class GearsOfWarQueryNpgsqlFixture : GearsOfWarQueryRelationalFixture<Npg
public GearsOfWarQueryNpgsqlFixture()
{
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.AddSingleton<ILoggerFactory>(new TestSqlLoggerFactory())
.BuildServiceProvider();
......@@ -34,10 +33,11 @@ public override NpgsqlTestStore CreateTestStore()
{
return NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(_connectionString);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(_connectionString)
.UseInternalServiceProvider(_serviceProvider);
using (var context = new GearsOfWarContext(_serviceProvider, optionsBuilder.Options))
using (var context = new GearsOfWarContext(optionsBuilder.Options))
{
// TODO: Delete DB if model changed
context.Database.EnsureDeleted();
......@@ -54,12 +54,18 @@ public override NpgsqlTestStore CreateTestStore()
public override GearsOfWarContext CreateContext(NpgsqlTestStore testStore)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder
.EnableSensitiveDataLogging()
.UseInternalServiceProvider(_serviceProvider)
.UseNpgsql(testStore.Connection);
var context = new GearsOfWarContext(_serviceProvider, optionsBuilder.Options);
var context = new GearsOfWarContext(optionsBuilder.Options);
context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
context.Database.UseTransaction(testStore.Transaction);
return context;
}
}
......
......@@ -3,10 +3,11 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.FunctionalTests;
using Xunit;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class GearsOfWarQueryNpgsqlTest : GearsOfWarQueryTestBase<NpgsqlTestStore, GearsOfWarQueryNpgsqlFixture>
{
......
......@@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class GraphUpdatesNpgsqlTest : GraphUpdatesNpgsqlTestBase<GraphUpdatesNpgsqlTest.GraphUpdatesNpgsqlFixture>
{
......
......@@ -3,11 +3,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.FunctionalTests;
using Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests.Utilities;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public abstract class GraphUpdatesNpgsqlTestBase<TFixture> : GraphUpdatesTestBase<NpgsqlTestStore, TFixture>
where TFixture : GraphUpdatesNpgsqlTestBase<TFixture>.GraphUpdatesNpgsqlFixtureBase, new()
......@@ -24,9 +25,7 @@ public abstract class GraphUpdatesNpgsqlFixtureBase : GraphUpdatesFixtureBase
protected GraphUpdatesNpgsqlFixtureBase()
{
_serviceProvider = new ServiceCollection()
.AddEntityFramework()
.AddNpgsql()
.ServiceCollection()
.AddEntityFrameworkNpgsql()
.AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
.BuildServiceProvider();
}
......@@ -40,7 +39,7 @@ public override NpgsqlTestStore CreateTestStore()
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(NpgsqlTestStore.CreateConnectionString(DatabaseName));
using (var context = new GraphUpdatesContext(_serviceProvider, optionsBuilder.Options))
using (var context = new GraphUpdatesContext(optionsBuilder.Options))
{
context.Database.EnsureDeleted();
if (context.Database.EnsureCreated())
......@@ -53,10 +52,11 @@ public override NpgsqlTestStore CreateTestStore()
public override DbContext CreateContext(NpgsqlTestStore testStore)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(testStore.Connection);
var optionsBuilder = new DbContextOptionsBuilder()
.UseNpgsql(testStore.Connection)
.UseInternalServiceProvider(_serviceProvider);
var context = new GraphUpdatesContext(_serviceProvider, optionsBuilder.Options);
var context = new GraphUpdatesContext(optionsBuilder.Options);
context.Database.UseTransaction(testStore.Transaction);
return context;
}
......
......@@ -3,9 +3,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Entity.FunctionalTests;
using Microsoft.EntityFrameworkCore.FunctionalTests;
namespace EntityFramework7.Npgsql.FunctionalTests
namespace Npgsql.EntityFrameworkCore.PostgreSQL.FunctionalTests
{
public class IncludeAsyncNpgsqlTest : IncludeAsyncTestBase<NorthwindQueryNpgsqlFixture>
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册