diff --git a/.gitignore b/.gitignore
index d2df1da5b5077d597142e85e19812ba900a4e81c..919fbcce6fc84fbfce0aaf71233447708c9d1667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -268,3 +268,6 @@ __pycache__/
 tools/*
 !tools/packages.config
 dist/
+
+# Dotnet Tool Manifest
+.config/*
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b339a45c43a1dcb4b80ab99e6224bc7232abd723..0ca40408b70e04dc3284756a5caf9ae348d1526b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,55 +1,71 @@
+include:
+  - project: coscine/tools/gitlab-ci-templates
+    file: 
+      - /dotnet.yml
+
 stages:
+  - migrate
+  - build
   - test
-  - release
-  - releasetrigger
+  - cleanup
+  - publish
+
+variables:
+  DOTNET_MAIN_PROJECT_FOLDER: Database
+  # Example DB_NAME = X_COSCINE_TMP_EF_1ecfd275
+  DB_NAME: "X_COSCINE_TMP_EF_$CI_COMMIT_SHORT_SHA"
+
+migrate:
+  stage: migrate
+  extends: .dotnet-windows-base
+  script: 
+    - dotnet tool install dotnet-ef; echo "1"
+    - dotnet tool update dotnet-ef
+    # Create new database and migrate to latest state
+    - dotnet build src\Database.Actions
+    - .\src\Database.Actions\bin\Debug\net5.0\Coscine.Database.Actions.exe --action-create --name $DB_NAME --source $DB_DATA_SOURCE --user $DB_USER_ID --pw $DB_PASSWORD
+    # Scaffold created database
+    - dotnet ef dbcontext scaffold "Data Source=$DB_DATA_SOURCE;Integrated Security=False;User ID=$DB_USER_ID;Password=$DB_PASSWORD;Database=$DB_NAME" Microsoft.EntityFrameworkCore.SqlServer -o DataModel -c "Model" -f --no-onconfiguring --project "src\Database"
+    # Remove the hardcoded Connection String inside \DataModel\Model.cs
+    - Set-Content -Path ".\src\Database\DataModel\Model.txt" -Value (Get-Content -Path ".\src\Database\DataModel\Model.cs" | where { $_ | Select-String -Pattern '#warning' -NotMatch } | where { $_ | Select-String -Pattern 'Data Source=' -NotMatch } ) -Force
+    - Set-Content -Path ".\src\Database\DataModel\Model.cs" -Value (Get-Content -Path ".\src\Database\DataModel\Model.txt") -Force
+    - Remove-Item ".\src\Database\DataModel\Model.txt"
+
+cleanup:
+  stage: cleanup
+  extends: .dotnet-windows-base
+  script: 
+    # Drop created database
+    - .\dist\Database.Actions\Coscine.Database.Actions.exe --action-drop --name $DB_NAME --source $DB_DATA_SOURCE --user $DB_USER_ID --pw $DB_PASSWORD
+  when: always
+
+build-branch:
+  extends: .build-branch
+
+build-nuget-release:
+  extends: .build-nuget-release
 
-cake:Test:
+test:  
+  extends: .dotnet-windows-base
   stage: test
   script:
-    - PowerShell .\build.ps1 -Target Test -Configuration Debug
-  variables:
-    GIT_STRATEGY: clone
-  artifacts:
-    reports:
-      junit: "./Artifacts/TestResults.xml"
-    paths:
-      - "./Artifacts/*"
-  except:
-    - master
-    - tags
-
-cake:Release:
-  stage: release
-  script:
-    - PowerShell .\build.ps1 -Target Release -Configuration Release --nugetApiKey="${NUGET_API_KEY}"
-  variables:
-    GIT_STRATEGY: clone
-  dependencies:
-    - cake:Test
-  artifacts:
-    paths:
-      - "./Artifacts/*"
+    - $env:DatabaseName=$DB_NAME
+    # Discover test projects in `src` folder
+    - dotnet test src
+  # TODO Add Dotnet Test coverage
   only:
-    - tags
+    # Do not run tests for chore commit by bot but re-run tests for the semver tag before pushing to npm
+    variables:
+      - $GITLAB_USER_ID != $GIT_BOT_USER_ID || $CI_COMMIT_TAG =~ /v[0-9]*\.[0-9]*\.[0-9]*/
 
-cake:Prerelease:
-  stage: release
-  script:
-    - PowerShell .\build.ps1 -Target Prerelease -Configuration Release
-  variables:
-    GIT_STRATEGY: clone
-  dependencies:
-    - cake:Test
-  artifacts:
-    paths:
-      - "./Artifacts/*"
-  except:
-    - tags
-    - master
-
-cake:GitlabRelease:
-    stage: releasetrigger
-    script:
-      - PowerShell .\build.ps1 -Target GitlabRelease --GitlabProjectPath="${CI_PROJECT_PATH}" --gitlabProjectId="${CI_PROJECT_ID}" --gitlabToken="${GITLAB_TOKEN}"
-    only:
-      - master
\ No newline at end of file
+publish-branch-prerelease:
+  extends: .publish-branch-prerelease
+
+publish-gitlab-release:
+  extends: .publish-gitlab-release
+
+publish-master-release:
+  extends: .publish-master-release
+
+publish-nuget-release:
+  extends: .publish-nuget-release
diff --git a/LICENSE b/LICENSE
index b8cd48a4db77aeee8a31fbec89cd7c8c4fb0b5ff..b2b571a29a4e6a417fc7c74b7ab46bc0cc9f1897 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2020 RWTH Aachen University
+Copyright (c) 2021 RWTH Aachen University
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/build.cake b/build.cake
deleted file mode 100644
index 81648ff61bbee492e1bc7b4390eb8e0cc33d3056..0000000000000000000000000000000000000000
--- a/build.cake
+++ /dev/null
@@ -1,351 +0,0 @@
-#tool nuget:?package=NUnit.ConsoleRunner&version=3.10.0
-#tool nuget:?package=vswhere&version=2.8.4
-#tool nuget:?package=GitVersion.CommandLine&version=5.1.3
-
-#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Json&version=4.0.0
-#addin nuget:https://api.nuget.org/v3/index.json?package=Newtonsoft.Json&version=11.0.2
-#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.FileHelpers&version=3.2.1
-
-using System.Net;
-using System.Net.Http;
-
-// Commandline arguments
-var target = Argument("target", "Default");
-var configuration = Argument("configuration", "Release");
-var nugetApiKey = Argument<string>("nugetApiKey", null);
-var version = Argument("nugetVersion", "");
-var gitlabProjectPath = Argument("gitlabProjectPath", "");
-var gitlabProjectId = Argument("gitlabProjectId", "");
-var gitlabToken = Argument("gitlabToken", "");
-
-// Define directories
-var projects = GetFiles("./**/*.csproj");
-var artifactsDir = Directory("./Artifacts");
-string nupkgDir;
-var solutionFile = GetFiles("./**/*.sln").First();
-var projectName = solutionFile.GetFilenameWithoutExtension().ToString();
-var nugetSource = "https://api.nuget.org/v3/index.json";
-var assemblyInfoSubPath = "Properties/AssemblyInfo.cs";
-var semanticVersion = "";
-string localNugetFeed;
-
-// get latest MSBuild version
-var vsLatest  = VSWhereLatest();	
-var msBuildPathX64 = (vsLatest == null) ? null : vsLatest.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe");
-
-Setup(context =>{
-	nupkgDir = $"{artifactsDir.ToString()}/nupkg";
-	var branch = GitVersion(new GitVersionSettings {
-			UpdateAssemblyInfo = false
-		}).BranchName.Replace("/", "-");
-
-	localNugetFeed = $"C:\\coscine\\LocalNugetFeeds\\{branch}";
-	Information("{0}", branch);
-	Information("Started at {0}", DateTime.Now);
-});
-
-Teardown(context =>{
-	Information("Finished at {0}", DateTime.Now);
-});
-
-Task("Clean")
-.Description("Cleans all build and artifacts directories")
-.Does(() =>{
-	var settings = new DeleteDirectorySettings {
-		Recursive = true,
-		Force = true
-	};
-	
-	var directoriesToClean = new List<DirectoryPath>();
-	
-	foreach(var project in projects) {
-		directoriesToClean.Add(Directory($"{project.GetDirectory()}/obj"));
-		directoriesToClean.Add(Directory($"{project.GetDirectory()}/bin"));
-	}
-	
-	directoriesToClean.Add(artifactsDir);
-
-	foreach(var dir in directoriesToClean) {
-		Information("Cleaning {0}", dir.ToString());
-		if (DirectoryExists(dir)) {
-			DeleteDirectory(dir, settings);
-			CreateDirectory(dir);
-		} else {
-			CreateDirectory(dir);
-		}
-	}
-});
-
-Task("Restore")
-.Does(() =>{
-	NuGetRestore(solutionFile, new NuGetRestoreSettings {
-		NoCache = true,
-		FallbackSource = new List<string>{ localNugetFeed },
-	});
-});
-
-Task("Test")
-.IsDependentOn("Build")
-.Does(() =>{
-	NUnit3($"./src/**/bin/{configuration}/*.Tests.dll", new NUnit3Settings {
-		// generate the xml file
-		NoResults = false,
-		Results = new NUnit3Result[] {
-			new NUnit3Result() {
-				FileName = $"{artifactsDir}/TestResults.xml",
-				Transform = $"{Context.Environment.WorkingDirectory}/nunit3-junit.xslt"
-			}
-		}
-	});
-});
-
-Task("GitVersion")
-.Does(() => {
-	if(string.IsNullOrWhiteSpace(version)) {
-		version = GitVersion(new GitVersionSettings {
-			UpdateAssemblyInfo = false
-		}).NuGetVersionV2;
-	}
-	var index = version.IndexOf("-");
-	semanticVersion = index > 0 ? version.Substring(0, index) : version;
-	Information("Version: {0}, SemanticVersion: {1}", version, semanticVersion);
-});
-
-Task("UpdateAssemblyInfo")
-.Does(() =>{
-	var index = version.IndexOf("-");
-	var semanticVersion = index > 0 ? version.Substring(0, index) : version;
-
-	foreach(var project in projects) {
-		CreateAssemblyInfo($"{project.GetDirectory()}/{assemblyInfoSubPath}", new AssemblyInfoSettings {
-			Product = project.GetFilenameWithoutExtension().ToString(),
-			Title = project.GetFilenameWithoutExtension().ToString(),
-			Company = "IT Center, RWTH Aachen University",
-			Version = semanticVersion,
-			FileVersion = semanticVersion,
-			InformationalVersion = version,
-			Copyright = $"{DateTime.Now.Year} IT Center, RWTH Aachen University",
-			Description = $"{project.GetFilenameWithoutExtension().ToString()} is a part of the CoScInE group."
-		});
-	}
-});
-
-Task("GitlabRelease")
-.IsDependentOn("GitVersion")
-.Does(() => {
-	var client = new HttpClient();
-	client.DefaultRequestHeaders.Add("PRIVATE-TOKEN", gitlabToken);
-	
-	// get the latest tag
-	var result = client.GetAsync($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/repository/tags").Result;
-	if(!result.IsSuccessStatusCode) {
-		throw new Exception("Tag query failed.");
-	}
-
-	var tagList = result.Content.ReadAsStringAsync().Result;
-	var jArray = JArray.Parse(tagList);
-	// null if not tags exists yet
-	var lastTag = jArray.Select(x => x["name"]).FirstOrDefault();
-
-	var url = $"https://git.rwth-aachen.de/{gitlabProjectPath}";
-	
-	if(url.EndsWith(".git")) {
-		url = url.Substring(0, url.Length - ".git".Length);
-	}
-
-	if(url.EndsWith("/")) {
-		url = url.Substring(0, url.Length - 1);
-	}
-
-	var description = "";
-	// First line of description
-	// Gitlab compare url, if something can be compared
-	if(lastTag == null) {
-		description = $"# {semanticVersion} ({DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day})\n\n\n";
-	} else {
-		description = $"# [{semanticVersion}]({url}/compare/{lastTag}...v{semanticVersion}) ({DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day})\n\n\n";
-	}
-
-	// From when will messages be parsed, null results in all messages
-	var logParam = "";
-	if(lastTag != null) {
-		logParam = $"{lastTag}..Head";
-	}
-
-	Information(lastTag);
-
-	IEnumerable<string> redirectedStandardOutput;
-	var exitCodeWithArgument =
-		StartProcess(
-			"git",
-			new ProcessSettings {
-				Arguments = $"log {logParam} --pretty=format:HASH%h:%B",
-				RedirectStandardOutput = true
-			},
-			out redirectedStandardOutput
-		);
-
-	var prefixList = new Dictionary<string, List<string>>{
-		{"Fix", new List<string>()},
-		{"Update", new List<string>()},
-		{"New", new List<string>()},
-		{"Breaking", new List<string>()},
-		{"Docs", new List<string>()},
-		{"Build", new List<string>()},
-		{"Upgrade", new List<string>()},
-		{"Chore", new List<string>()},
-	};
-
-	var currentHash = "";
-	// Output last line of process output.
-	foreach(var line in redirectedStandardOutput) {
-		var commitMessage = "";
-		if(line.StartsWith("HASH")) {
-			currentHash = line.Substring("HASH".Length);
-			currentHash = currentHash.Substring(0, currentHash.IndexOf(":"));
-			commitMessage = line.Substring(currentHash.Length + line.IndexOf(currentHash) + 1);
-		} else {
-			commitMessage = line;
-		}
-
-		foreach(var kv in prefixList) {
-			if(commitMessage.StartsWith($"{kv.Key}:")) {
-				kv.Value.Add($"* {commitMessage.Substring(kv.Key.Length + 1).Trim()} {currentHash}");
-				break;
-			}
-		};
-	}
-	
-	foreach(var kv in prefixList) {
-		if(kv.Value.Any()) {
-			description += $" ### {kv.Key}\n\n";
-			foreach(var line in kv.Value) {
-				description += $"{line}\n";
-			}
-			description += "\n";
-		}
-	}
-	// correctly escape the json newlines
-	description = description.Replace("\n", "\\n");
-	Information("Description: {0}", description);
-
-	// create tag
-	result = client.PostAsync($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/repository/tags?tag_name=v{semanticVersion}&ref=master", null).Result;
-	Information("Create tag: {0}", result.Content.ReadAsStringAsync().Result);
-	if(!result.IsSuccessStatusCode) {
-		throw new Exception("Tag creation failed.");
-	}
-
-	// create release
-	var json = $"{{\"name\": \"v{semanticVersion}\", \"tag_name\": \"v{semanticVersion}\", \"description\": \"{description}\"}}";
-	var content = new StringContent(json, Encoding.UTF8, "application/json");
-	result = client.PostAsync($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/releases", content).Result;
-	Information("Create release: {0}", result.Content.ReadAsStringAsync().Result);
-	if(!result.IsSuccessStatusCode) {
-		throw new Exception("Release creation failed.");
-	}
-});
-
-Task("Build")
-.IsDependentOn("Clean")
-.IsDependentOn("GitVersion")
-.IsDependentOn("UpdateAssemblyInfo")
-.IsDependentOn("Restore")
-.Does(() =>{
-		var frameworkSettingsWindows = new MSBuildSettings {
-			Configuration = configuration
-		};
-		
-		frameworkSettingsWindows.ToolPath = msBuildPathX64;
-		frameworkSettingsWindows.WorkingDirectory = Context.Environment.WorkingDirectory;
-
-		if (configuration.Equals("Release")) {
-			frameworkSettingsWindows.WithProperty("DebugSymbols", "false");
-			frameworkSettingsWindows.WithProperty("DebugType", "None");
-		}
-
-		// Use MSBuild
-		Information("Building {0}", solutionFile);
-		MSBuild(solutionFile, frameworkSettingsWindows);
-});
-
-Task("NugetPack")
-.IsDependentOn("Build")
-.Does(() =>{
-	foreach(var project in projects) {
-			var nuspec = $"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec";
-			if(!project.ToString().EndsWith(".Tests") && FileExists(nuspec))
-			{
-				var settings = new NuGetPackSettings 
-				{
-					OutputDirectory = nupkgDir,
-					Version = version,
-					Properties = new Dictionary<string, string>
-					{
-						{ "Configuration", configuration}
-					}
-				};				
-				NuGetPack(project.ToString(), settings);
-			}
-		}
-});
-
-Task("NugetPush")
-.IsDependentOn("NugetPack")
-.Does(() =>{
-	var nupkgs = GetFiles($"{nupkgDir}/*.nupkg");
-	Information("Need to push {0} packages", nupkgs.Count);
-	if(!String.IsNullOrWhiteSpace(nugetApiKey)) {
-		foreach(var nupkg in nupkgs) {
-			Information("Pushing {0}", nupkg);
-			NuGetPush(nupkg, new NuGetPushSettings {
-				Source = nugetSource,
-				ApiKey = nugetApiKey
-			});
-		}
-	} else {
-		Information("NugetApiKey is not set. Can't push.");
-		throw new Exception("NugetApiKey is not set. Can't push.");
-	}
-});
-
-Task("CopyToArtifacts")
-.Does(() =>{
-	foreach(var project in projects) {
-		if(!project.GetDirectory().ToString().EndsWith(".Tests")
-		&& !FileExists($"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec")
-		&& DirectoryExists(project.GetDirectory()))
-		{
-			Information("Copying {0}/* to {1}", $"{project.GetDirectory()}/bin/{configuration}", artifactsDir);
-			CopyDirectory($"{project.GetDirectory()}/bin/{configuration}/", artifactsDir);
-		}
-	}
-});
-
-Task("NugetPushLocal")
-.IsDependentOn("NugetPack")
-.Does(() =>{	
-	var nupkgs = GetFiles($"{nupkgDir}/*.nupkg");
-	foreach(var nupkg in nupkgs) {
-		if(!DirectoryExists(localNugetFeed)) {
-			CreateDirectory(localNugetFeed);
-		}
-		CopyFile(nupkg.ToString(), $"{localNugetFeed}\\{nupkg.GetFilename()}");
-	}
-});
-
-Task("Prerelease")
-.IsDependentOn("Build")
-.IsDependentOn("CopyToArtifacts")
-.IsDependentOn("NugetPushLocal");
-
-Task("Release")
-.IsDependentOn("NugetPack")
-.IsDependentOn("CopyToArtifacts")
-.IsDependentOn("NugetPushLocal")
-.IsDependentOn("NugetPush");
-
-Task("Default")
-.IsDependentOn("Test");
-
-RunTarget(target);
diff --git a/build.ps1 b/build.ps1
deleted file mode 100644
index f83382e8e4092ba6cf32a47f9dfa4e211c878430..0000000000000000000000000000000000000000
--- a/build.ps1
+++ /dev/null
@@ -1,255 +0,0 @@
-#The MIT License (MIT)
-#
-#Copyright (c) 2014 - 2016 Patrik Svensson, Mattias Karlsson, Gary Ewan Park and contributors
-#
-#Permission is hereby granted, free of charge, to any person obtaining a copy of
-#this software and associated documentation files (the "Software"), to deal in
-#the Software without restriction, including without limitation the rights to
-#use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-#the Software, and to permit persons to whom the Software is furnished to do so,
-#subject to the following conditions:
-#
-#The above copyright notice and this permission notice shall be included in all
-#copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-#FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-#COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-#IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-##########################################################################
-# This is the Cake bootstrapper script for PowerShell.
-# This file was downloaded from https://github.com/cake-build/resources
-# Feel free to change this file to fit your needs.
-##########################################################################
-
-<#
-
-.SYNOPSIS
-This is a Powershell script to bootstrap a Cake build.
-
-.DESCRIPTION
-This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
-and execute your Cake build script with the parameters you provide.
-
-.PARAMETER Script
-The build script to execute.
-.PARAMETER Target
-The build script target to run.
-.PARAMETER Configuration
-The build configuration to use.
-.PARAMETER Verbosity
-Specifies the amount of information to be displayed.
-.PARAMETER ShowDescription
-Shows description about tasks.
-.PARAMETER DryRun
-Performs a dry run.
-.PARAMETER Experimental
-Uses the nightly builds of the Roslyn script engine.
-.PARAMETER Mono
-Uses the Mono Compiler rather than the Roslyn script engine.
-.PARAMETER SkipToolPackageRestore
-Skips restoring of packages.
-.PARAMETER ScriptArgs
-Remaining arguments are added here.
-
-.LINK
-https://cakebuild.net
-
-#>
-
-[CmdletBinding()]
-Param(
-    [string]$Script = "build.cake",
-    [string]$Target,
-    [string]$Configuration,
-    [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
-    [string]$Verbosity,
-    [switch]$ShowDescription,
-    [Alias("WhatIf", "Noop")]
-    [switch]$DryRun,
-    [switch]$Experimental,
-    [switch]$Mono,
-    [switch]$SkipToolPackageRestore,
-    [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
-    [string[]]$ScriptArgs
-)
-
-[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
-function MD5HashFile([string] $filePath)
-{
-    if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
-    {
-        return $null
-    }
-
-    [System.IO.Stream] $file = $null;
-    [System.Security.Cryptography.MD5] $md5 = $null;
-    try
-    {
-        $md5 = [System.Security.Cryptography.MD5]::Create()
-        $file = [System.IO.File]::OpenRead($filePath)
-        return [System.BitConverter]::ToString($md5.ComputeHash($file))
-    }
-    finally
-    {
-        if ($file -ne $null)
-        {
-            $file.Dispose()
-        }
-    }
-}
-
-function GetProxyEnabledWebClient
-{
-    $wc = New-Object System.Net.WebClient
-    $proxy = [System.Net.WebRequest]::GetSystemWebProxy()
-    $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials        
-    $wc.Proxy = $proxy
-    return $wc
-}
-
-Write-Host "Preparing to run build script..."
-
-if(!$PSScriptRoot){
-    $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
-}
-
-$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
-$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
-$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
-$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
-$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
-$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
-$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
-$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
-$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
-$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
-
-# Make sure tools folder exists
-if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
-    Write-Verbose -Message "Creating tools directory..."
-    New-Item -Path $TOOLS_DIR -Type directory | out-null
-}
-
-# Make sure that packages.config exist.
-if (!(Test-Path $PACKAGES_CONFIG)) {
-    Write-Verbose -Message "Downloading packages.config..."    
-    try {        
-        $wc = GetProxyEnabledWebClient
-        $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
-        Throw "Could not download packages.config."
-    }
-}
-
-# Try find NuGet.exe in path if not exists
-if (!(Test-Path $NUGET_EXE)) {
-    Write-Verbose -Message "Trying to find nuget.exe in PATH..."
-    $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
-    $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
-    if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
-        Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
-        $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
-    }
-}
-
-# Try download NuGet.exe if not exists
-if (!(Test-Path $NUGET_EXE)) {
-    Write-Verbose -Message "Downloading NuGet.exe..."
-    try {
-        $wc = GetProxyEnabledWebClient
-        $wc.DownloadFile($NUGET_URL, $NUGET_EXE)
-    } catch {
-        Throw "Could not download NuGet.exe."
-    }
-}
-
-# Save nuget.exe path to environment to be available to child processed
-$ENV:NUGET_EXE = $NUGET_EXE
-
-# Restore tools from NuGet?
-if(-Not $SkipToolPackageRestore.IsPresent) {
-    Push-Location
-    Set-Location $TOOLS_DIR
-
-    # Check for changes in packages.config and remove installed tools if true.
-    [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
-    if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
-      ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
-        Write-Verbose -Message "Missing or changed package.config hash..."
-        Remove-Item * -Recurse -Exclude packages.config,nuget.exe
-    }
-
-    Write-Verbose -Message "Restoring tools from NuGet..."
-    $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
-
-    if ($LASTEXITCODE -ne 0) {
-        Throw "An error occurred while restoring NuGet tools."
-    }
-    else
-    {
-        $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
-    }
-    Write-Verbose -Message ($NuGetOutput | out-string)
-
-    Pop-Location
-}
-
-# Restore addins from NuGet
-if (Test-Path $ADDINS_PACKAGES_CONFIG) {
-    Push-Location
-    Set-Location $ADDINS_DIR
-
-    Write-Verbose -Message "Restoring addins from NuGet..."
-    $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
-
-    if ($LASTEXITCODE -ne 0) {
-        Throw "An error occurred while restoring NuGet addins."
-    }
-
-    Write-Verbose -Message ($NuGetOutput | out-string)
-
-    Pop-Location
-}
-
-# Restore modules from NuGet
-if (Test-Path $MODULES_PACKAGES_CONFIG) {
-    Push-Location
-    Set-Location $MODULES_DIR
-
-    Write-Verbose -Message "Restoring modules from NuGet..."
-    $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
-
-    if ($LASTEXITCODE -ne 0) {
-        Throw "An error occurred while restoring NuGet modules."
-    }
-
-    Write-Verbose -Message ($NuGetOutput | out-string)
-
-    Pop-Location
-}
-
-# Make sure that Cake has been installed.
-if (!(Test-Path $CAKE_EXE)) {
-    Throw "Could not find Cake.exe at $CAKE_EXE"
-}
-
-
-
-# Build Cake arguments
-$cakeArguments = @("$Script");
-if ($Target) { $cakeArguments += "-target=$Target" }
-if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
-if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
-if ($ShowDescription) { $cakeArguments += "-showdescription" }
-if ($DryRun) { $cakeArguments += "-dryrun" }
-if ($Experimental) { $cakeArguments += "-experimental" }
-if ($Mono) { $cakeArguments += "-mono" }
-$cakeArguments += $ScriptArgs
-
-# Start Cake
-Write-Host "Running build script..."
-&$CAKE_EXE $cakeArguments
-exit $LASTEXITCODE
diff --git a/build.sh b/build.sh
deleted file mode 100644
index d088917ed78538ff57cf654cf71aad6bf045d655..0000000000000000000000000000000000000000
--- a/build.sh
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env bash
-
-#The MIT License (MIT)
-#
-#Copyright (c) 2014 - 2016 Patrik Svensson, Mattias Karlsson, Gary Ewan Park and contributors
-#
-#Permission is hereby granted, free of charge, to any person obtaining a copy of
-#this software and associated documentation files (the "Software"), to deal in
-#the Software without restriction, including without limitation the rights to
-#use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-#the Software, and to permit persons to whom the Software is furnished to do so,
-#subject to the following conditions:
-#
-#The above copyright notice and this permission notice shall be included in all
-#copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-#FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-#COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-#IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-##########################################################################
-# This is the Cake bootstrapper script for Linux and OS X.
-# This file was downloaded from https://github.com/cake-build/resources
-# Feel free to change this file to fit your needs.
-##########################################################################
-
-# Define directories.
-SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-TOOLS_DIR=$SCRIPT_DIR/tools
-NUGET_EXE=$TOOLS_DIR/nuget.exe
-CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
-PACKAGES_CONFIG=$TOOLS_DIR/packages.config
-PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum
-
-# Define md5sum or md5 depending on Linux/OSX
-MD5_EXE=
-if [[ "$(uname -s)" == "Darwin" ]]; then
-    MD5_EXE="md5 -r"
-else
-    MD5_EXE="md5sum"
-fi
-
-# Define default arguments.
-SCRIPT="build.cake"
-TARGET="Default"
-CONFIGURATION="Release"
-VERBOSITY="verbose"
-DRYRUN=
-SHOW_VERSION=false
-SCRIPT_ARGUMENTS=()
-
-# Parse arguments.
-for i in "$@"; do
-    case $1 in
-        -s|--script) SCRIPT="$2"; shift ;;
-        -t|--target) TARGET="$2"; shift ;;
-        -c|--configuration) CONFIGURATION="$2"; shift ;;
-        -v|--verbosity) VERBOSITY="$2"; shift ;;
-        -d|--dryrun) DRYRUN="-dryrun" ;;
-        --version) SHOW_VERSION=true ;;
-        --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
-        *) SCRIPT_ARGUMENTS+=("$1") ;;
-    esac
-    shift
-done
-
-# Make sure the tools folder exist.
-if [ ! -d "$TOOLS_DIR" ]; then
-  mkdir "$TOOLS_DIR"
-fi
-
-# Make sure that packages.config exist.
-if [ ! -f "$TOOLS_DIR/packages.config" ]; then
-    echo "Downloading packages.config..."
-    curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages
-    if [ $? -ne 0 ]; then
-        echo "An error occurred while downloading packages.config."
-        exit 1
-    fi
-fi
-
-# Download NuGet if it does not exist.
-if [ ! -f "$NUGET_EXE" ]; then
-    echo "Downloading NuGet..."
-    curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
-    if [ $? -ne 0 ]; then
-        echo "An error occurred while downloading nuget.exe."
-        exit 1
-    fi
-fi
-
-# Restore tools from NuGet.
-pushd "$TOOLS_DIR" >/dev/null
-if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then
-    find . -type d ! -name . | xargs rm -rf
-fi
-
-mono "$NUGET_EXE" install -ExcludeVersion
-if [ $? -ne 0 ]; then
-    echo "Could not restore NuGet packages."
-    exit 1
-fi
-
-$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5
-
-popd >/dev/null
-
-# Make sure that Cake has been installed.
-if [ ! -f "$CAKE_EXE" ]; then
-    echo "Could not find Cake.exe at '$CAKE_EXE'."
-    exit 1
-fi
-
-# Start Cake
-if $SHOW_VERSION; then
-    exec mono "$CAKE_EXE" -version
-else
-    exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
-fi
\ No newline at end of file
diff --git a/src/.tools/linq2db.t4models/BouncyCastle.Crypto.dll b/src/.tools/linq2db.t4models/BouncyCastle.Crypto.dll
deleted file mode 100644
index 7a8034b95caafe059d3167c04e92bd05b754a8db..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/BouncyCastle.Crypto.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/FirebirdSql.Data.FirebirdClient.dll b/src/.tools/linq2db.t4models/FirebirdSql.Data.FirebirdClient.dll
deleted file mode 100644
index 24b7905d9c0e2c1ba0708e662d699f14f0b9d68f..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/FirebirdSql.Data.FirebirdClient.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/Init.ps1 b/src/.tools/linq2db.t4models/Init.ps1
deleted file mode 100644
index d7e710d55907097cf93d3d3e546801028e12d906..0000000000000000000000000000000000000000
--- a/src/.tools/linq2db.t4models/Init.ps1
+++ /dev/null
@@ -1,9 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-# get the active solution
-$solution           = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
-$solutionPath       = [System.IO.Path]::GetDirectoryName($solution.FullName)
-$linq2dbToolsPath   = [System.IO.Path]::Combine($solutionPath, ".tools", "linq2db.t4models")
-
-# tools copy
-xcopy $("$toolsPath\*.*") $("$linq2dbToolsPath\") /y /e
diff --git a/src/.tools/linq2db.t4models/Microsoft.SqlServer.Types.dll b/src/.tools/linq2db.t4models/Microsoft.SqlServer.Types.dll
deleted file mode 100644
index 1ccde4ab41861e147c71e420d78328995842559d..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/Microsoft.SqlServer.Types.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/MySql.Data.dll b/src/.tools/linq2db.t4models/MySql.Data.dll
deleted file mode 100644
index a95e69eb83eee7e6fc4b12ff56af06f023e2a7a4..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/MySql.Data.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/Npgsql.dll b/src/.tools/linq2db.t4models/Npgsql.dll
deleted file mode 100644
index 84f09e327dd21b7172b8cc56dabd6ca92a8bf416..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/Npgsql.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/Oracle.ManagedDataAccess.dll b/src/.tools/linq2db.t4models/Oracle.ManagedDataAccess.dll
deleted file mode 100644
index c2eaa0a917cace842e286841f1d0bd3fe2ee3a05..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/Oracle.ManagedDataAccess.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/SQLite.Interop.dll b/src/.tools/linq2db.t4models/SQLite.Interop.dll
deleted file mode 100644
index 35bdfe6f949968983f3e1b5e0cef13764816f6bb..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/SQLite.Interop.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/System.Data.SQLite.dll b/src/.tools/linq2db.t4models/System.Data.SQLite.dll
deleted file mode 100644
index 08c21c1c76518fcf1f4afb08d9ab96fa27119af8..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/System.Data.SQLite.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/System.Threading.Tasks.Extensions.dll b/src/.tools/linq2db.t4models/System.Threading.Tasks.Extensions.dll
deleted file mode 100644
index dfc4cdf62c8f7c243d694ed7b96424d3f2e457be..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/System.Threading.Tasks.Extensions.dll and /dev/null differ
diff --git a/src/.tools/linq2db.t4models/linq2db.dll b/src/.tools/linq2db.t4models/linq2db.dll
deleted file mode 100644
index 2f5c0a1119ee13f3fb606085f4b1464b22e56d43..0000000000000000000000000000000000000000
Binary files a/src/.tools/linq2db.t4models/linq2db.dll and /dev/null differ
diff --git a/src/Database.Actions/Database.Actions.csproj b/src/Database.Actions/Database.Actions.csproj
new file mode 100644
index 0000000000000000000000000000000000000000..668b353d05c51a22c7673346f49758fda29ddb26
--- /dev/null
+++ b/src/Database.Actions/Database.Actions.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+	  <RootNamespace>Coscine.Database.Actions</RootNamespace>
+	  <AssemblyName>Coscine.Database.Actions</AssemblyName>
+    <TargetFramework>net5.0</TargetFramework>
+  </PropertyGroup>
+	<ItemGroup>
+		<PackageReference Include="Coscine.Database.Helpers" Version="2.*-*" />
+		<PackageReference Include="Coscine.Migrations" Version="2.*-*" />
+	</ItemGroup>
+</Project>
diff --git a/src/Database.Actions/Program.cs b/src/Database.Actions/Program.cs
new file mode 100644
index 0000000000000000000000000000000000000000..128ae6f8560ad0996dfdf9d024258e6a0f06052c
--- /dev/null
+++ b/src/Database.Actions/Program.cs
@@ -0,0 +1,170 @@
+using Coscine.Database.Helpers;
+using Coscine.Migrations;
+using System;
+
+namespace Database.Actions
+{
+    public class Program
+    {
+        private const string STR_DB_NAME = "--name";
+        private const string STR_DB_SOURCE = "--source";
+        private const string STR_DB_USER = "--user";
+        private const string STR_DB_PW = "--pw";
+
+        private const string STR_ACTION_CREATE = "--action-create";
+        private const string STR_ACTION_DROP = "--action-drop";
+
+        private static string Instructions =
+            $"Possible actions: \n" +
+            $"{STR_ACTION_CREATE} {STR_DB_NAME} <DATABASE NAME> {STR_DB_SOURCE} <DATABASE_SOURCE> {STR_DB_USER} <DATABASE_USER_ID> {STR_DB_PW} <DATABASE_PASSWORD> \n" +
+            $"{STR_ACTION_DROP} {STR_DB_NAME} <DATABASE NAME> {STR_DB_SOURCE} <DATABASE_SOURCE> {STR_DB_USER} <DATABASE_USER_ID> {STR_DB_PW} <DATABASE_PASSWORD> \n";
+
+        private static CoscineMigrations migrator = new CoscineMigrations();
+        private static DatabaseMasterHelper helper = new DatabaseMasterHelper();
+
+        public static void Main(string[] args)
+        {
+            if (args.Length != 9)
+            {
+                OutputRedMessage($"The input is not valid.");
+                PrintHelp();
+            }
+            else
+            {
+                bool pointer;
+                switch (args[0].ToLower())
+                {
+                    // --action-create
+                    case STR_ACTION_CREATE:
+                        pointer = AssembleSettings(args);
+                        if (pointer)
+                            CreateTemporaryDatabase();
+                        else
+                        {
+                            OutputRedMessage($"Could not finish the requested operation {args[0]}. Exiting.");
+                            return;
+                        }
+                        break;
+
+                    // --action-drop
+                    case STR_ACTION_DROP:
+                        pointer = AssembleSettings(args);
+                        if (pointer)
+                            DropTemporaryDatabase();
+                        else
+                        {
+                            OutputRedMessage($"Could not finish the requested operation {args[0]}. Exiting.");
+                            return;
+                        }
+                        break;
+
+                    case "--help":
+                        PrintHelp();
+                        break;
+                    default:
+                        OutputRedMessage($"Please start your input with the keyword \"{STR_ACTION_CREATE}\" or \"{STR_ACTION_DROP}\".");
+                        PrintHelp();
+                        break;
+                }
+            }
+        }
+
+        private static void PrintHelp()
+        {
+            Console.WriteLine("These are the possible actions:");
+            Console.ForegroundColor = ConsoleColor.Cyan;
+            Console.WriteLine(Instructions);
+            Console.ResetColor();
+        }
+
+        private static void CreateTemporaryDatabase()
+        {
+            if (helper.DatabaseExists(helper.ConnectionSettings.Database))
+                OutputYellowMessage($"Database {helper.ConnectionSettings.Database} already exists.");
+            try
+            {
+                helper.EnsureDatabase(helper.ConnectionSettings.Database);
+                migrator.MigrateUp();
+                OutputGreenMessage($"Database {helper.ConnectionSettings.Database} created/updated successfully!");
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine($"Something went wrong trying to create database {helper.ConnectionSettings.Database}.");
+                Console.WriteLine("Error Log: " + e);
+            }
+        }
+
+        private static void DropTemporaryDatabase()
+        {
+            if (helper.DatabaseExists(helper.ConnectionSettings.Database))
+            {
+                try
+                {
+                    OutputGreenMessage($"Found database {helper.ConnectionSettings.Database}.");
+                    helper.KillConnectionsToDatabase(helper.ConnectionSettings.Database);
+                    helper.DropDatabase(helper.ConnectionSettings.Database);
+                    OutputGreenMessage($"Database {helper.ConnectionSettings.Database} deleted successfully!");
+                }
+                catch (Exception e)
+                {
+                    OutputRedMessage($"Something went wrong trying to delete database {helper.ConnectionSettings.Database}.");
+                    Console.WriteLine("Error Message: " + e);
+                }
+            }
+            else OutputYellowMessage($"Database {helper.ConnectionSettings.Database} does not exist!");
+        }
+
+        private static void OutputRedMessage(string message)
+        {
+            Console.ForegroundColor = ConsoleColor.Red;
+            Console.WriteLine(message);
+            Console.ResetColor();
+        }
+
+        private static void OutputYellowMessage(string message)
+        {
+            Console.ForegroundColor = ConsoleColor.Yellow;
+            Console.WriteLine(message);
+            Console.ResetColor();
+        }
+
+        private static void OutputGreenMessage(string message)
+        {
+            Console.ForegroundColor = ConsoleColor.Green;
+            Console.WriteLine(message);
+            Console.ResetColor();
+        }
+
+        private static bool AssembleSettings(string[] args)
+        {
+            ConfigurationConnectionSettings settings = new ConfigurationConnectionSettings();
+            // start from index = 1, everything after --action-create...
+            for (int ind = 1; ind < args.Length; ind += 2)
+            {
+                switch (args[ind].ToLower())
+                {
+                    case STR_DB_NAME:
+                        settings.Database = args[ind + 1];
+                        break;
+                    case STR_DB_SOURCE:
+                        settings.DataSource = args[ind + 1];
+                        break;
+                    case STR_DB_USER:
+                        settings.UserId = args[ind + 1];
+                        break;
+                    case STR_DB_PW:
+                        settings.Password = args[ind + 1];
+                        break;
+                    default:
+                        OutputYellowMessage($"The input {args[ind]} is not valid.");
+                        PrintHelp();
+                        return false;
+                }
+            }
+            migrator.ConnectionSettings = settings;
+            helper.ConnectionSettings = settings;
+            OutputGreenMessage("Configuration settings successfully extracted from input.");
+            return true;
+        }
+    }
+}
diff --git a/src/Database.T4/Coscine.Database.T4.Key.snk b/src/Database.T4/Coscine.Database.T4.Key.snk
deleted file mode 100644
index 7b2d8233a8a39ce2e8b92d46351ec9c8f81dff8c..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/Coscine.Database.T4.Key.snk and /dev/null differ
diff --git a/src/Database.T4/CustomT4.targets b/src/Database.T4/CustomT4.targets
deleted file mode 100644
index ad3885531ad83578f05b9c329ca7967f665820e4..0000000000000000000000000000000000000000
--- a/src/Database.T4/CustomT4.targets
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <!-- Set up common properties for T4 text templating -->
-  <ItemGroup>
-    <T4ParameterValues Include="ProjectDir">
-      <Value>$(ProjectDir)</Value>
-    </T4ParameterValues>
-    <T4ParameterValues Include="LinqToDBT4ToolsDirectory">
-      <Value>$(LinqToDBT4ToolsDirectory)</Value>
-    </T4ParameterValues>
-  </ItemGroup>
-</Project>
\ No newline at end of file
diff --git a/src/Database.T4/DataModel/CsDatabase.tt b/src/Database.T4/DataModel/CsDatabase.tt
deleted file mode 100644
index ad2eb0270db7257506b4a58cef16f3c1e2b6983a..0000000000000000000000000000000000000000
--- a/src/Database.T4/DataModel/CsDatabase.tt
+++ /dev/null
@@ -1,59 +0,0 @@
-<#@ template language="C#" debug="True" hostSpecific="False"                           #>
-<#@ output extension=".generated.cs"                                                  #>
-<#@ include file="$(ProjectDir)\LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" #>
-<#@ include file="$(ProjectDir)\LinqToDB.Templates\PluralizationService.ttinclude"     #>
-
-<#@ assembly name="$(ProjectDir)..\packages\Coscine.Configuration.1.6.0\lib\net461\Coscine.Configuration.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Coscine.Migrations.1.11.0\lib\net461\Coscine.Migrations.dll" #>
-<#@ assembly name="$(ProjectDir)..\packages\Coscine.Database.Helpers.1.2.0\lib\net461\Coscine.Database.Helpers.dll" #>
-
-<#@ assembly name="$(ProjectDir)..\packages\Consul.1.6.1.1\lib\net461\Consul.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.DependencyInjection.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.Runner.3.2.11\lib\net461\FluentMigrator.Runner.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.Runner.Core.3.2.11\lib\net461\FluentMigrator.Runner.Core.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.Logging.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.Options.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Options.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.Abstractions.3.2.11\lib\net461\FluentMigrator.Abstractions.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.Logging.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.Runner.SqlServer.3.2.11\lib\net461\FluentMigrator.Runner.SqlServer.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.3.2.11\lib\net461\FluentMigrator.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.Primitives.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\FluentMigrator.Extensions.SqlServer.3.2.11\lib\net461\FluentMigrator.Extensions.SqlServer.dll"#>
-<#@ assembly name="$(ProjectDir)..\packages\Microsoft.Extensions.Configuration.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll"#>
-
-<#@ import namespace="System" #>
-<#@ import namespace="Coscine.Configuration" #>
-<#@ import namespace="Coscine.Migrations" #>
-<#@ import namespace="Coscine.Database.Helpers" #>
-
-<# NamespaceName = "Coscine.Database.DataModel"; #>
-
-<#
-
-    var _databaseName = $"Coscine_Database.T4_model_{Guid.NewGuid()}";
-
-    var settings = new ConfigurationConnectionSettings() { Configuration = new ConsulConfiguration() };
-
-    settings.LoadSettingsFromConfiguration();
-    settings.Database = _databaseName;
-
-	var _migrator = new CoscineMigrations()
-    {
-        ConnectionSettings = settings
-    };
-
-	var _helper = new DatabaseMasterHelper
-    {
-        ConnectionSettings = settings
-    };
-
-    _helper.EnsureDatabase(_databaseName);
-    _migrator.MigrateUp();
-
-	DataContextName ="CoscineDB";
-	LoadSqlServerMetadata(_migrator.ConnectionSettings.DataSource, _migrator.ConnectionSettings.Database, _migrator.ConnectionSettings.UserId, _migrator.ConnectionSettings.Password);
-	GenerateModel();
-    _helper.KillConnectionsToDatabase(_databaseName);
-    _helper.DropDatabase(_databaseName);
-#>
\ No newline at end of file
diff --git a/src/Database.T4/Database.T4.csproj b/src/Database.T4/Database.T4.csproj
deleted file mode 100644
index ff025aaec91c520699207af7d69f61bb816f5a2e..0000000000000000000000000000000000000000
--- a/src/Database.T4/Database.T4.csproj
+++ /dev/null
@@ -1,271 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\linq2db.SqlServer.3.1.0\build\linq2db.SqlServer.props" Condition="Exists('..\packages\linq2db.SqlServer.3.1.0\build\linq2db.SqlServer.props')" />
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{CB50129B-A890-4DF9-9C40-CD6354076A3C}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Coscine.Database.T4</RootNamespace>
-    <AssemblyName>Coscine.Database.T4</AssemblyName>
-    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <Deterministic>true</Deterministic>
-    <NuGetPackageImportStamp>
-    </NuGetPackageImportStamp>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SignAssembly>true</SignAssembly>
-  </PropertyGroup>
-  <PropertyGroup>
-    <AssemblyOriginatorKeyFile>Coscine.Database.T4.Key.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Consul, Version=1.6.1.1, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
-      <HintPath>..\packages\Consul.1.6.1.1\lib\net461\Consul.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Configuration, Version=1.6.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Configuration.1.6.0\lib\net461\Coscine.Configuration.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Database.Helpers, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Database.Helpers.1.2.0\lib\net461\Coscine.Database.Helpers.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Migrations, Version=1.11.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Migrations.1.11.0\lib\net461\Coscine.Migrations.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="FluentMigrator, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.3.2.11\lib\net461\FluentMigrator.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Abstractions, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Abstractions.3.2.11\lib\net461\FluentMigrator.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Oracle.3.2.11\lib\net461\FluentMigrator.Extensions.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Postgres.3.2.11\lib\net461\FluentMigrator.Extensions.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Extensions.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlServer.3.2.11\lib\net461\FluentMigrator.Extensions.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.3.2.11\lib\net461\FluentMigrator.Runner.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Core, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Core.3.2.11\lib\net461\FluentMigrator.Runner.Core.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Db2, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Db2.3.2.11\lib\net461\FluentMigrator.Runner.Db2.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Firebird, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Firebird.3.2.11\lib\net461\FluentMigrator.Runner.Firebird.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Hana, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Hana.3.2.11\lib\net461\FluentMigrator.Runner.Hana.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Jet, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Jet.3.2.11\lib\net461\FluentMigrator.Runner.Jet.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.MySql, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.MySql.3.2.11\lib\net461\FluentMigrator.Runner.MySql.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Oracle.3.2.11\lib\net461\FluentMigrator.Runner.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Postgres.3.2.11\lib\net461\FluentMigrator.Runner.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Redshift, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Redshift.3.2.11\lib\net461\FluentMigrator.Runner.Redshift.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Runner.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SQLite, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SQLite.3.2.11\lib\net461\FluentMigrator.Runner.SQLite.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServer.3.2.11\lib\net461\FluentMigrator.Runner.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServerCe, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\lib\net461\FluentMigrator.Runner.SqlServerCe.dll</HintPath>
-    </Reference>
-    <Reference Include="linq2db, Version=3.1.0.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
-      <HintPath>..\packages\linq2db.3.1.0\lib\net46\linq2db.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Data.Sqlite, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Data.Sqlite.Core.5.0.2\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Options, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Options.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Options.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Primitives, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Primitives.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ComponentModel.Annotations.4.4.1\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.DataAnnotations" />
-    <Reference Include="System.Configuration" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SqlClient.4.8.2\lib\net461\System.Data.SqlClient.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Net.Http.WebRequest" />
-    <Reference Include="System.Numerics" />
-    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.4.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
-      <Private>True</Private>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <Import Project="CustomT4.targets" />
-  <ItemGroup>
-    <None Include="CustomT4.targets" />
-    <Compile Include="DataModel\CsDatabase.generated.cs">
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>CsDatabase.tt</DependentUpon>
-    </Compile>
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="app.config" />
-    <None Include="Coscine.Database.T4.Key.snk" />
-    <None Include="DataModel\CsDatabase.tt">
-      <Generator>TextTemplatingFileGenerator</Generator>
-      <LastGenOutput>CsDatabase.generated.cs</LastGenOutput>
-    </None>
-    <None Include="LinqToDB.Templates\DataAnnotations.ttinclude" />
-    <None Include="LinqToDB.Templates\DataModel.ttinclude" />
-    <None Include="LinqToDB.Templates\EditableObject.ttinclude" />
-    <None Include="LinqToDB.Templates\Equatable.ttinclude" />
-    <None Include="LinqToDB.Templates\Humanizer.ttinclude" />
-    <None Include="LinqToDB.Templates\LinqToDB.SqlServer.SqlTypes.Tools.ttinclude" />
-    <None Include="LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" />
-    <None Include="LinqToDB.Templates\LinqToDB.SqlServer.ttinclude" />
-    <None Include="LinqToDB.Templates\LinqToDB.Tools.ttinclude" />
-    <None Include="LinqToDB.Templates\LinqToDB.ttinclude" />
-    <None Include="LinqToDB.Templates\MultipleFiles.ttinclude" />
-    <None Include="LinqToDB.Templates\NotifyDataErrorInfo.ttinclude" />
-    <None Include="LinqToDB.Templates\NotifyPropertyChanged.ttinclude" />
-    <None Include="LinqToDB.Templates\ObsoleteAttributes.ttinclude" />
-    <None Include="LinqToDB.Templates\PluralizationService.ttinclude" />
-    <None Include="LinqToDB.Templates\T4Model.ttinclude" />
-    <None Include="LinqToDB.Templates\Validation.ttinclude" />
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="LinqToDB.Templates\CopyMe.SqlServer.tt.txt" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <!-- Get the Visual Studio version: -->
-    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
-    <!-- Keep the next element all on one line: -->
-    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />
-  <PropertyGroup>
-    <TransformOnBuild>true</TransformOnBuild>
-    <OverwriteReadOnlyOutputFiles>true</OverwriteReadOnlyOutputFiles>
-    <TransformOutOfDateOnly>false</TransformOutOfDateOnly>
-    <ProjectDir>$(MSBuildProjectDirectory)\</ProjectDir>
-    <LinqToDBT4ToolsDirectory>$(MSBuildProjectDirectory)\..\.tools\linq2db.t4models\</LinqToDBT4ToolsDirectory>
-  </PropertyGroup>
-  <PropertyGroup>
-    <PreBuildEvent />
-  </PropertyGroup>
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\linq2db.SqlServer.3.1.0\build\linq2db.SqlServer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\linq2db.SqlServer.3.1.0\build\linq2db.SqlServer.props'))" />
-    <Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
-    <Error Condition="!Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets'))" />
-  </Target>
-  <Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
-  <Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
-</Project>
\ No newline at end of file
diff --git a/src/Database.T4/LinqToDB.Templates/CopyMe.SqlServer.tt.txt b/src/Database.T4/LinqToDB.Templates/CopyMe.SqlServer.tt.txt
deleted file mode 100644
index 65785e768481b688f6863dbb48b11e8b8f8703bf..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/CopyMe.SqlServer.tt.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-<#@ template language="C#" debug="True" hostSpecific="True"                           #>
-<#@ output extension=".generated.cs"                                                  #>
-<#@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)LinqToDB.SqlServer.Tools.ttinclude" #>
-<#@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)PluralizationService.ttinclude"     #>
-<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" #>
-<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude"     #>
-<#
-	/*
-		1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model
-		   and copy content from this file to it. For example:
-
-			MyProject
-				DataModels
-					MyDatabase.tt
-
-		2. Modify the connection settings below to connect to your database.
-
-		3. Add connection string to the web/app.config file:
-
-			<connectionStrings>
-				<add name="MyDatabase" providerName="System.Data.SqlClient"
-					connectionString="Data Source=.;Database=MyDatabase;User Id=User;Password=TestPassword;" />
-			</connectionStrings>
-
-		4. To access your database use the following code:
-
-			using (var db = new MyDatabaseDB())
-			{
-				var q =
-					from c in db.Customers
-					select c;
-
-				foreach (var c in q)
-					Console.WriteLine(c.ContactName);
-			}
-
-		5. See more at https://linq2db.github.io/articles/T4.html
-
-		If you need to use the Microsoft.SqlServer.Types namespace, install the Microsoft.SqlServer.Types nuget,
-		and replace the following include at the top of this file:
-
-			"$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude"
-
-		with
-
-			"$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.SqlTypes.Tools.ttinclude"
-
-		IMPORTANT: if running .tt file gives you error like this:
-		"error : Failed to resolve include text for file: C:\...\$(LinqToDBT4<SOME_DB>TemplatesDirectory)LinqToDB.<DB_NAME>.Tools.ttinclude"
-		check tt file properties.
-		Custom tool must be set to TextTemplatingFileGenerator, not TextTemplatingFilePreprocessor or any other value.
-	*/
-
-	NamespaceName = "DataModels";
-
-	// to configure GetSchemaOptions properties, add them here, before load metadata call
-
-	LoadSqlServerMetadata("MyServer", "MyDatabase", "User", "Password");
-//	LoadSqlServerMetadata(".", "MyDatabase"); // Integrated Security
-//	LoadSqlServerMetadata(string connectionString);
-
-	// to adjust loaded database model before generation, add your code here, after load metadata, but before GenerateModel() call
-
-	GenerateModel();
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/DataAnnotations.ttinclude b/src/Database.T4/LinqToDB.Templates/DataAnnotations.ttinclude
deleted file mode 100644
index a98aea24cf313345913d948297bba0784055801a..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/DataAnnotations.ttinclude
+++ /dev/null
@@ -1,65 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			beforeGenerateModel();
-			DataAnnotationsImpl();
-		};
-	}
-#>
-<#+
-void DataAnnotationsImpl()
-{
-	foreach (Class cl in GetTreeNodes(Model).OfType<Class>())
-	{
-		foreach (var p in GetTreeNodes(cl).OfType<Property>())
-		{
-			if (p.DisplayName != null)
-			{
-				p.Attributes.Add(new Attribute("Display", "Name=" + ToStringLiteral(p.DisplayName)) { IsSeparated = true });
-			}
-
-			if (p.IsRequired)
-			{
-				var attr = new Attribute("Required") { IsSeparated = true };
-
-				if (p.IsRequiredMessage != null)
-					attr.Parameters.Add(string.Format("ErrorMessage=" + ToStringLiteral(p.IsRequiredMessage), p.DisplayName ?? p.Name));
-
-				p.Attributes.Add(attr);
-			}
-
-			if (p.StringLength > 0)
-			{
-				var attr = new Attribute("StringLength", p.StringLength.ToString()) { IsSeparated = true };
-
-				if (p.StringLengthMessage != null)
-					attr.Parameters.Add(string.Format("ErrorMessage=" + ToStringLiteral(p.StringLengthMessage), p.DisplayName ?? p.Name));
-
-				p.Attributes.Add(attr);
-
-//				p.Attributes.Add(
-//					new Attribute("StringLength",
-//						p.StringLength.ToString(),
-//						"ErrorMessage=" + ToStringLiteral(string.Format(
-//							"The {0} must be a string with a maximum length of {1}.",
-//							p.DisplayName ?? "field",
-//							p.StringLength)))
-//					{
-//						IsSeparated = true
-//					});
-			}
-		}
-	}
-}
-
-partial class Property
-{
-	public string DisplayName;
-	public bool   IsRequired;
-	public string IsRequiredMessage;
-	public int    StringLength;
-	public string StringLengthMessage;
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/DataModel.ttinclude b/src/Database.T4/LinqToDB.Templates/DataModel.ttinclude
deleted file mode 100644
index aa531b60653fa3e86e34a30c752a3b86b6cc4dfe..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/DataModel.ttinclude
+++ /dev/null
@@ -1,915 +0,0 @@
-<#@ assembly name="System.Data"                #>
-<#@ import namespace="System.Data"             #>
-<#@ import namespace="LinqToDB.SchemaProvider" #>
-<#@ import namespace="LinqToDB.Data"           #>
-<#@ include file="T4Model.ttinclude"           #>
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			GenerateTypesFromMetadata();
-			beforeGenerateModel();
-		};
-	}
-#><#+
-
-string   NamespaceName
-{
-	get { return Model.Namespace.Name;  }
-	set { Model.Namespace.Name = value; }
-}
-
-string   ServerName                    = null;
-string   DatabaseName                  = null;
-string   DataContextName               = null;
-string   BaseDataContextClass          = null;
-string   BaseEntityClass               = null;
-string   OneToManyAssociationType      = "IEnumerable<{0}>";
-
-bool     GenerateDatabaseInfo          = true;
-bool     GenerateDatabaseName          = false;
-bool     GenerateConstructors          = true;
-string   DefaultConfiguration          = null;
-bool     GenerateAssociations          = true;
-bool     GenerateBackReferences        = true;
-bool     GenerateAssociationExtensions = false;
-bool     ReplaceSimilarTables          = true;
-bool     IncludeDefaultSchema          = true;
-
-Class    DataContextObject;
-
-bool PluralizeClassNames                 = false;
-bool SingularizeClassNames               = true;
-bool PluralizeDataContextPropertyNames   = true;
-bool SingularizeDataContextPropertyNames = false;
-
-bool NormalizeNames                      = true;
-bool NormalizeNamesWithoutUnderscores    = false;
-static bool EnforceModelNullability      = true;
-
-private Func<string, bool, string> _toValidName;
-Func<string, bool, string> ToValidName
-{
-	get { return _toValidName ?? ToValidNameDefault; }
-	set { _toValidName = value; }
-}
-
-private Func<string, bool, string> _convertToCompilabl;
-Func<string, bool, string> ConvertToCompilable
-{
-	get { return _convertToCompilabl ?? ConvertToCompilableDefault; }
-	set { _convertToCompilabl = value; }
-}
-
-private Func<ForeignKey, string> _getAssociationExtensionPluralName;
-Func<ForeignKey, string> GetAssociationExtensionPluralName
-{
-	get { return _getAssociationExtensionPluralName ?? GetAssociationExtensionPluralNameDefault; }
-	set { _getAssociationExtensionPluralName = value; }
-}
-
-private Func<ForeignKey, string> _getAssociationExtensionSingularName;
-Func<ForeignKey, string> GetAssociationExtensionSinglularName
-{
-	get { return _getAssociationExtensionSingularName ?? GetAssociationExtensionSinglularNameDefault; }
-	set { _getAssociationExtensionSingularName = value; }
-}
-
-LinqToDB.SchemaProvider.GetSchemaOptions GetSchemaOptions =
-	new LinqToDB.SchemaProvider.GetSchemaOptions();
-
-LinqToDB.SqlProvider.ISqlBuilder SqlBuilder;
-
-Func<TableSchema,Table> LoadProviderSpecificTable = tableSchema => null;
-
-static Func<ColumnSchema,string>                 ConvertColumnMemberType          = (c) => c.MemberType;
-static Func<TableSchema,ColumnSchema,string>     ConvertTableColumnMemberType     = (t,c) => ConvertColumnMemberType(c);
-static Func<ProcedureSchema,ColumnSchema,string> ConvertProcedureColumnMemberType = (t,c) => ConvertColumnMemberType(c);
-
-HashSet<string> KeyWords = new HashSet<string>
-{
-	"abstract", "as",       "base",     "bool",    "break",     "byte",      "case",       "catch",     "char",    "checked",
-	"class",    "const",    "continue", "decimal", "default",   "delegate",  "do",         "double",    "else",    "enum",
-	"event",    "explicit", "extern",   "false",   "finally",   "fixed",     "float",      "for",       "foreach", "goto",
-	"if",       "implicit", "in",       "int",     "interface", "internal",  "is",         "lock",      "long",    "new",
-	"null",     "object",   "operator", "out",     "override",  "params",    "private",    "protected", "public",  "readonly",
-	"ref",      "return",   "sbyte",    "sealed",  "short",     "sizeof",    "stackalloc", "static",    "struct",  "switch",
-	"this",     "throw",    "true",     "try",     "typeof",    "uint",      "ulong",      "unchecked", "unsafe",  "ushort",
-	"using",    "virtual",  "volatile", "void",    "while",     "namespace", "string"
-};
-
-void LoadServerMetadata(DataConnection dataConnection)
-{
-	SqlBuilder = dataConnection.DataProvider.CreateSqlBuilder(dataConnection.MappingSchema);
-
-	var sp = dataConnection.DataProvider.GetSchemaProvider();
-	var db = sp.GetSchema(dataConnection, GetSchemaOptions);
-
-	if (DatabaseName == null && GenerateDatabaseName)
-		DatabaseName = db.Database;
-
-	if (DataContextName == null)
-		DataContextObject.Name = DataContextName = ToValidName(db.Database, true) + "DB";
-
-	if (GenerateDatabaseInfo)
-	{
-		DataContextObject.Comment.Add("/ <summary>");
-		DataContextObject.Comment.Add("/ Database       : " + db.Database);
-		DataContextObject.Comment.Add("/ Data Source    : " + db.DataSource);
-		DataContextObject.Comment.Add("/ Server Version : " + db.ServerVersion);
-		DataContextObject.Comment.Add("/ </summary>");
-	}
-
-	var tables = db.Tables
-		.Where(t => !t.IsProviderSpecific)
-		.Select(t => new
-		{
-			t,
-			key = t.IsDefaultSchema ? t.TableName : t.SchemaName + "." + t.TableName,
-			table = new Table
-			{
-				TableSchema             = t,
-				IsDefaultSchema         = t.IsDefaultSchema,
-				Schema                  = t.IsDefaultSchema && !IncludeDefaultSchema || string.IsNullOrEmpty(t.SchemaName) ? null : t.SchemaName,
-				BaseClass               = BaseEntityClass,
-				TableName               = t.TableName,
-				TypeName                = t.TypeName,
-				DataContextPropertyName = t.TypeName,
-				IsView                  = t.IsView,
-				IsProviderSpecific      = false,
-				Description             = t.Description,
-				Columns                 = t.Columns.ToDictionary(
-					c => c.ColumnName,
-					c => new Column(new ModelType(ConvertTableColumnMemberType(t, c), !IsValueType(ConvertTableColumnMemberType(t, c)), c.IsNullable))
-					{
-						ColumnName      = c.ColumnName,
-						ColumnType      = c.ColumnType,
-						DataType        = "DataType." + c.DataType,
-						Length          = c.Length,
-						Precision       = c.Precision,
-						Scale           = c.Scale,
-						IsNullable      = c.IsNullable,
-						IsIdentity      = c.IsIdentity,
-						IsPrimaryKey    = c.IsPrimaryKey,
-						PrimaryKeyOrder = c.PrimaryKeyOrder,
-						MemberName      = CheckType(c.SystemType, c.MemberName),
-						SkipOnInsert    = c.SkipOnInsert,
-						SkipOnUpdate    = c.SkipOnUpdate,
-						Description     = c.Description,
-					})
-			}
-		})
-		.ToList();
-
-	if (PluralizeClassNames || SingularizeClassNames)
-	{
-		var foundNames = new HashSet<string>(tables.Select(t => t.table.Schema + '.' + t.table.TypeName));
-
-		foreach (var t in tables)
-		{
-			var newName = t.table.TypeName;
-				newName =
-					PluralizeClassNames   ? ToPlural  (newName) :
-					SingularizeClassNames ? ToSingular(newName) : newName;
-
-			if (newName != t.table.TypeName)
-			{
-				if (!foundNames.Contains(t.table.Schema + '.' + newName))
-				{
-					t.table.TypeName = newName;
-					foundNames.Add(t.table.Schema + '.' + newName);
-				}
-			}
-		}
-	}
-
-	if (PluralizeDataContextPropertyNames || SingularizeDataContextPropertyNames)
-	{
-		var foundNames = new HashSet<string>(tables.Select(t => t.table.Schema + '.' + t.table.DataContextPropertyName));
-
-		foreach (var t in tables)
-		{
-			var newName = t.table.DataContextPropertyName;
-				newName =
-					PluralizeDataContextPropertyNames   ? ToPlural  (newName) :
-					SingularizeDataContextPropertyNames ? ToSingular(newName) : newName;
-
-			if (newName != t.table.TypeName)
-			{
-				if (!foundNames.Contains(t.table.Schema + '.' + newName))
-				{
-					t.table.DataContextPropertyName = newName;
-					foundNames.Add(t.table.Schema + '.' + newName);
-				}
-			}
-		}
-	}
-
-	tables.AddRange(db.Tables
-		.Where(t => t.IsProviderSpecific)
-		.Select(t => new
-		{
-			t,
-			key = t.IsDefaultSchema ? t.TableName : t.SchemaName + "." + t.TableName,
-			table = LoadProviderSpecificTable(t)
-		})
-		.Where(t => t.table != null));
-
-	foreach (var t in tables)
-		Tables.Add(t.key, t.table);
-
-	var keys =
-	(
-		from t in tables
-		from k in t.t.ForeignKeys
-		let otherTable = tables.Where(tbl => tbl.t == k.OtherTable).Select(tbl => tbl.table).Single()
-		select new
-		{
-			k,
-			k.KeyName,
-			t,
-			key = new ForeignKey
-			{
-				KeyName         = k.KeyName,
-				OtherTable      = otherTable,
-				OtherColumns    = k.OtherColumns.Select(c => otherTable.Columns[c.ColumnName]).ToList(),
-				ThisColumns     = k.ThisColumns. Select(c => t.table.   Columns[c.ColumnName]).ToList(),
-				CanBeNull       = k.CanBeNull,
-				MemberName      = k.MemberName,
-				AssociationType = (AssociationType)(int)k.AssociationType,
-			}
-		}
-	).ToList();
-
-	foreach (var key in keys)
-	{
-		key.t.table.ForeignKeys.Add(
-			key.k.OtherTable.IsDefaultSchema ? key.KeyName : key.k.OtherTable.SchemaName + "." + key.KeyName,
-			key.key);
-
-		if (key.k.BackReference != null)
-			key.key.BackReference = keys.First(k => k.k == key.k.BackReference).key;
-
-		key.key.MemberName = key.key.MemberName.Replace(".", string.Empty);
-
-		key.key.MemberName = key.key.AssociationType == AssociationType.OneToMany ?
-			ToPlural(key.key.MemberName) : ToSingular(key.key.MemberName);
-	}
-
-	var procedures = db.Procedures
-		.Select(p => new
-		{
-			p,
-			key = p.IsDefaultSchema ? p.ProcedureName : p.SchemaName + "." + p.ProcedureName,
-			proc = new Procedure
-			{
-				Schema              = (p.IsDefaultSchema && !IncludeDefaultSchema) || string.IsNullOrEmpty(p.SchemaName)? null : p.SchemaName,
-				ProcedureName       = p.ProcedureName,
-				Name                = ToValidName(p.MemberName, true),
-				IsFunction          = p.IsFunction,
-				IsTableFunction     = p.IsTableFunction,
-				IsAggregateFunction = p.IsAggregateFunction,
-				IsDefaultSchema     = p.IsDefaultSchema,
-				IsLoaded            = p.IsLoaded,
-				ResultTable         = p.ResultTable == null ? null :
-					new Table
-					{
-						TypeName = ToValidName(
-							PluralizeClassNames   ? ToPlural  (p.ResultTable.TypeName) :
-							SingularizeClassNames ? ToSingular(p.ResultTable.TypeName) : p.ResultTable.TypeName, true),
-						Columns  = ToDictionary(
-							p.ResultTable.Columns,
-							c => c.ColumnName,
-							c => new Column(new ModelType(ConvertProcedureColumnMemberType(p, c), !IsValueType(ConvertProcedureColumnMemberType(p, c)), c.IsNullable))
-							{
-								ColumnName      = c.ColumnName,
-								ColumnType      = c.ColumnType,
-								IsNullable      = c.IsNullable,
-								IsIdentity      = c.IsIdentity,
-								IsPrimaryKey    = c.IsPrimaryKey,
-								PrimaryKeyOrder = c.PrimaryKeyOrder,
-								MemberName      = CheckColumnName(CheckType(c.SystemType, c.MemberName)),
-								SkipOnInsert    = c.SkipOnInsert,
-								SkipOnUpdate    = c.SkipOnUpdate,
-								Description     = c.Description,
-							},
-							(c,n) =>
-							{
-								c.IsDuplicateOrEmpty = true;
-								return "$" + (c.MemberName = "Column" + n);
-							})
-					},
-				ResultException = p.ResultException,
-				SimilarTables   = p.SimilarTables == null ? new List<Table>() :
-					p.SimilarTables
-						.Select(t => tables.Single(tbl => tbl.t == t).table)
-						.ToList(),
-				ProcParameters  = p.Parameters
-					.Select(pr => new Parameter
-					{
-						SchemaName    = pr.SchemaName,
-						SchemaType    = pr.SchemaType,
-						IsIn          = pr.IsIn,
-						IsOut         = pr.IsOut,
-						IsResult      = pr.IsResult,
-						Size          = pr.Size,
-						ParameterName = CheckParameterName(CheckType(pr.SystemType, pr.ParameterName)),
-						ParameterType = pr.ParameterType,
-						SystemType    = pr.SystemType,
-						DataType      = pr.DataType.ToString(),
-						IsNullable    = pr.IsNullable
-					})
-					.ToList(),
-			}
-		})
-		.ToList();
-
-	foreach (var p in procedures)
-	{
-		if (ReplaceSimilarTables)
-			if (p.proc.SimilarTables.Count() == 1 || p.proc.SimilarTables.Count(t => !t.IsView) == 1)
-				p.proc.ResultTable = p.proc.SimilarTables.Count() == 1 ?
-					p.proc.SimilarTables[0] :
-					p.proc.SimilarTables.First(t => !t.IsView);
-
-		Procedures[p.key] = p.proc;
-	}
-}
-
-Dictionary<string,TR> ToDictionary<T,TR>(IEnumerable<T> source, Func<T,string> keyGetter, Func<T,TR> objGetter, Func<TR,int,string> getKeyName)
-{
-	var dic     = new Dictionary<string,TR>();
-	var current = 1;
-
-	foreach (var item in source)
-	{
-		var key = keyGetter(item);
-		var obj = objGetter(item);
-
-		if (string.IsNullOrEmpty(key) || dic.ContainsKey(key))
-			key = getKeyName(obj, current);
-
-		dic.Add(key, obj);
-
-		current++;
-	}
-
-	return dic;
-}
-
-string CheckType(Type type, string typeName)
-{
-	if (!Model.Usings.Contains(type.Namespace))
-		Model.Usings.Add(type.Namespace);
-
-	if (type.IsGenericType)
-		foreach (var argType in type.GetGenericArguments())
-			CheckType(argType, null);
-
-	return typeName;
-}
-
-string CheckColumnName(string memberName)
-{
-	if (string.IsNullOrEmpty(memberName))
-		memberName = "Empty";
-	else
-	{
-		memberName = memberName
-			.Replace("%", "Percent")
-			.Replace(">", "Greater")
-			.Replace("<", "Lower")
-			.Replace("+", "Plus")
-			.Replace('(', '_')
-			.Replace(')', '_')
-			.Replace('-', '_')
-			.Replace('|', '_')
-			.Replace(',', '_')
-			.Replace('"', '_')
-			.Replace("'", "_")
-			.Replace(".", "_")
-			.Replace("\u00A3", "Pound");
-
-		if (KeyWords.Contains(memberName))
-			memberName = "@" + memberName;
-	}
-	return memberName;
-}
-
-string CheckParameterName(string parameterName)
-{
-	var invalidParameterNames = new List<string>
-	{
-		"@DataType"
-	};
-
-	var result = parameterName;
-	while (invalidParameterNames.Contains(result))
-	{
-		result = result + "_";
-	}
-	return result;
-}
-
-Action AfterLoadMetadata = () => {};
-
-void LoadMetadata(DataConnection dataConnection)
-{
-	if (DataContextObject == null)
-	{
-		DataContextObject = new Class(DataContextName) { BaseClass = BaseDataContextClass, };
-
-		Model.Types.Add(DataContextObject);
-	}
-
-	LoadServerMetadata(dataConnection);
-
-	if (Tables.Values.SelectMany(_ => _.ForeignKeys.Values).Any(_ => _.AssociationType == AssociationType.OneToMany))
-		Model.Usings.Add("System.Collections.Generic");
-
-	foreach (var t in Tables.Values)
-	{
-		if (KeyWords.Contains(t.TypeName))
-			t.TypeName = "@" + t.TypeName;
-
-		if (KeyWords.Contains(t.DataContextPropertyName))
-			t.DataContextPropertyName = "@" + t.DataContextPropertyName;
-
-		t.TypeName                = ConvertToCompilable(t.TypeName,                true);
-		t.DataContextPropertyName = ConvertToCompilable(t.DataContextPropertyName, true);
-
-		foreach (var col in t.Columns.Values)
-		{
-			if (KeyWords.Contains(col.MemberName))
-				col.MemberName = "@" + col.MemberName;
-
-			col.MemberName = ConvertToCompilable(col.MemberName, true);
-
-			if (col.MemberName == t.TypeName)
-				col.MemberName += "Column";
-		}
-
-		foreach (var fk in t.ForeignKeys.Values)
-		{
-			if (KeyWords.Contains(fk.MemberName))
-				fk.MemberName = "@" + fk.MemberName;
-
-			fk.MemberName = ConvertToCompilable(fk.MemberName, true);
-
-			if (fk.MemberName == t.TypeName)
-				fk.MemberName += "_FK";
-		}
-	}
-
-	foreach (var t in Tables.Values)
-	{
-		var hasDuplicates = t.Columns.Values
-				.Select(c => c.MemberName)
-				.Concat(t.ForeignKeys.Values.Select(f => f.MemberName))
-				.ToLookup(n => n)
-				.Any(g => g.Count() > 1);
-
-		if (hasDuplicates)
-		{
-			foreach (var fk in t.ForeignKeys.Values)
-			{
-				var mayDuplicate = t.Columns.Values
-					.Select(c => c.MemberName)
-					.Concat(t.ForeignKeys.Values.Where(f => f != fk).Select(f => f.MemberName));
-
-				fk.MemberName = SuggestNoDuplicate(mayDuplicate, fk.MemberName, "FK");
-			}
-
-			foreach (var col in t.Columns.Values)
-			{
-				var mayDuplicate = t.Columns.Values
-					.Where(c => c != col)
-					.Select(c => c.MemberName)
-					.Concat(t.ForeignKeys.Values.Select(fk => fk.MemberName));
-
-				col.MemberName = SuggestNoDuplicate(mayDuplicate, col.MemberName, null);
-			}
-		}
-	}
-
-	foreach (var proc in Procedures.Values)
-	{
-		proc.Name = ConvertToCompilable(proc.Name, false);
-
-		if (KeyWords.Contains(proc.Name))
-			proc.Name = "@" + proc.Name;
-
-		foreach (var param in proc.ProcParameters)
-		{
-			if (KeyWords.Contains(param.ParameterName))
-				param.ParameterName = ConvertToCompilable("@" + param.ParameterName, true);
-		}
-	}
-
-	AfterLoadMetadata();
-}
-
-string SuggestNoDuplicate(IEnumerable<string> currentNames, string newName, string prefix)
-{
-	var names = new HashSet<string>(currentNames);
-	var result = newName;
-	if (names.Contains(result))
-	{
-		if (!string.IsNullOrEmpty(prefix))
-			result = prefix + result;
-		if (names.Contains(result))
-		{
-			var counter = 0;
-
-			// get last 6 digits
-			var idx = result.Length;
-			while (idx > 0 && idx > result.Length - 6 && char.IsDigit(result[idx - 1]))
-				idx--;
-			var number = result.Substring(idx);
-
-			if (!string.IsNullOrEmpty(number))
-			{
-				if (int.TryParse(number, out counter))
-				{
-					result = result.Remove(result.Length - number.Length);
-				}
-			}
-
-			do
-			{
-				++counter;
-				if (!names.Contains(result + counter))
-				{
-					result = result + counter;
-					break;
-				}
-			}
-			while(true);
-		}
-	}
-
-	return result;
-}
-
-string ConvertToCompilableDefault(string name, bool mayRemoveUnderscore)
-{
-	var query =
-		from c in name
-		select char.IsLetterOrDigit(c) || c == '@' ? c : '_';
-
-	return ToValidName(new string(query.ToArray()), mayRemoveUnderscore);
-}
-
-Table GetTable(string name)
-{
-	Table tbl;
-
-	if (Tables.TryGetValue(name, out tbl))
-		return tbl;
-
-	WriteLine("#error Table '" + name +  "' not found.");
-	WriteLine("/*");
-	WriteLine("\tExisting tables:");
-	WriteLine("");
-
-	foreach (var key in Tables.Keys)
-		WriteLine("\t" + key);
-
-	WriteLine(" */");
-
-	throw new ArgumentException("Table '" + name +  "' not found.");
-}
-
-Procedure GetProcedure(string name)
-{
-	Procedure proc;
-
-	if (Procedures.TryGetValue(name, out proc))
-		return proc;
-
-	WriteLine("#error Procedure '" + name +  "' not found.");
-	WriteLine("");
-	WriteLine("/*");
-	WriteLine("\tExisting procedures:");
-	WriteLine("");
-
-	foreach (var key in Procedures.Keys)
-		WriteLine("\t" + key);
-
-	WriteLine(" */");
-
-	throw new ArgumentException("Procedure '" + name +  "' not found.");
-}
-
-Column GetColumn(string tableName, string columnName)
-{
-	var tbl = GetTable(tableName);
-
-	Column col;
-
-	if (tbl.Columns.TryGetValue(columnName, out col))
-		return col;
-
-	WriteLine("#error Column '" + tableName + "'.'" + columnName +  "' not found.");
-	WriteLine("");
-	WriteLine("/*");
-	WriteLine("\tExisting '" + tableName + "'columns:");
-	WriteLine("");
-
-	foreach (var key in tbl.Columns.Keys)
-		WriteLine("\t" + key);
-
-	WriteLine(" */");
-
-	throw new ArgumentException("Column '" + tableName + "'.'" + columnName +  "' not found.");
-}
-
-ForeignKey GetFK(string tableName, string fkName)
-{
-	return GetForeignKey(tableName, fkName);
-}
-
-ForeignKey GetForeignKey(string tableName, string fkName)
-{
-	var tbl = GetTable(tableName);
-
-	ForeignKey col;
-
-	if (tbl.ForeignKeys.TryGetValue(fkName, out col))
-		return col;
-
-	WriteLine("#error FK '" + tableName + "'.'" + fkName +  "' not found.");
-	WriteLine("");
-	WriteLine("/*");
-	WriteLine("\tExisting '" + tableName + "'FKs:");
-	WriteLine("");
-
-	foreach (var key in tbl.ForeignKeys.Keys)
-		WriteLine("\t" + key);
-
-	WriteLine(" */");
-
-	throw new ArgumentException("FK '" + tableName + "'.'" + fkName +  "' not found.");
-}
-
-
-public TableContext SetTable(string tableName,
-	string TypeName                = null,
-	string DataContextPropertyName = null)
-{
-	var ctx = new TableContext { Transformation = this, TableName = tableName };
-
-	if (TypeName != null || DataContextPropertyName != null)
-	{
-		var t = GetTable(tableName);
-
-		if (TypeName                != null) t.TypeName                = TypeName;
-		if (DataContextPropertyName != null) t.DataContextPropertyName = DataContextPropertyName;
-	}
-
-	return ctx;
-}
-
-public class TableContext
-{
-	public GeneratedTextTransformation Transformation;
-	public string                      TableName;
-
-	public TableContext Column(string columnName,
-		string MemberName  = null,
-		string Type        = null,
-		bool?  IsNullable  = null,
-		string Conditional = null)
-	{
-		var c = Transformation.GetColumn(TableName, columnName);
-
-		if (MemberName  != null) c.MemberName  = MemberName;
-		if (Type        != null) c.TypeBuilder = () => Type;
-		if (IsNullable  != null) c.IsNullable  = IsNullable.Value;
-		if (Conditional != null) c.Conditional = Conditional;
-
-		return this;
-	}
-
-	public TableContext FK(string fkName,
-		string           MemberName      = null,
-		AssociationType? AssociationType = null,
-		bool?            CanBeNull       = null)
-	{
-		var c = Transformation.GetFK(TableName, fkName);
-
-		if (MemberName      != null) c.MemberName      = MemberName;
-		if (AssociationType != null) c.AssociationType = AssociationType.Value;
-		if (CanBeNull       != null) c.CanBeNull       = CanBeNull.Value;
-
-		return this;
-	}
-}
-
-
-Dictionary<string,Table>     Tables     = new Dictionary<string,Table>    ();
-Dictionary<string,Procedure> Procedures = new Dictionary<string,Procedure>();
-
-public partial class Table : Class
-{
-	public TableSchema TableSchema             { get; set; }
-	public string      Schema                  { get; set; }
-	public string      TableName               { get; set; }
-	public string      DataContextPropertyName { get; set; }
-	public MemberBase  DataContextProperty     { get; set; }
-	public bool        IsView                  { get; set; }
-	public bool        IsProviderSpecific      { get; set; }
-	public bool        IsDefaultSchema         { get; set; }
-	public string      Description             { get; set; }
-	public string      AliasPropertyName       { get; set; }
-	public string      AliasTypeName           { get; set; }
-	public string      TypePrefix              { get; set; }
-
-	public string TypeName
-	{
-		get { return Name;  }
-		set { Name = value; }
-	}
-
-	public Dictionary<string,Column>     Columns;
-	public Dictionary<string,ForeignKey> ForeignKeys = new Dictionary<string,ForeignKey>();
-}
-
-public partial class Column : Property
-{
-	public Column()
-	{
-	}
-
-	public Column(ModelType type)
-	{
-		ModelType = type;
-		TypeBuilder = () => ModelType.ToTypeName();
-	}
-
-	public string    ColumnName; // Column name in database
-	public bool      IsNullable;
-	public bool      IsIdentity;
-	public string    ColumnType; // Type of the column in database
-	public string    DataType;
-	public long?     Length;
-	public int?      Precision;
-	public int?      Scale;
-	public DbType    DbType;
-	public string    Description;
-	public bool      IsPrimaryKey;
-	public int       PrimaryKeyOrder;
-	public bool      SkipOnUpdate;
-	public bool      SkipOnInsert;
-	public bool      IsDuplicateOrEmpty;
-	public bool      IsDiscriminator;
-	public string    AliasName;
-
-	public string MemberName
-	{
-		get { return Name;  }
-		set { Name = value; }
-	}
-
-	public ModelType ModelType { get; }
-
-	protected internal override bool EnforceNotNullable => EnableNullableReferenceTypes && EnforceModelNullability && ModelType != null && ModelType.IsReference && !ModelType.IsNullable;
-}
-
-public enum AssociationType
-{
-	Auto,
-	OneToOne,
-	OneToMany,
-	ManyToOne,
-}
-
-public partial class ForeignKey : Property
-{
-	public string       KeyName;
-	public Table        OtherTable;
-	public List<Column> ThisColumns;
-	public List<Column> OtherColumns;
-	public bool         CanBeNull;
-	public ForeignKey   BackReference;
-
-	public string MemberName
-	{
-		get { return Name;  }
-		set { Name = value; }
-	}
-
-	private AssociationType _associationType = AssociationType.Auto;
-	public  AssociationType  AssociationType
-	{
-		get { return _associationType; }
-		set
-		{
-			_associationType = value;
-
-			if (BackReference != null)
-			{
-				switch (value)
-				{
-					case AssociationType.Auto      : BackReference.AssociationType = AssociationType.Auto;      break;
-					case AssociationType.OneToOne  : BackReference.AssociationType = AssociationType.OneToOne;  break;
-					case AssociationType.OneToMany : BackReference.AssociationType = AssociationType.ManyToOne; break;
-					case AssociationType.ManyToOne : BackReference.AssociationType = AssociationType.OneToMany; break;
-				}
-			}
-		}
-	}
-
-	protected internal override bool EnforceNotNullable => EnableNullableReferenceTypes && EnforceModelNullability && (!CanBeNull || AssociationType == AssociationType.OneToMany);
-}
-
-public partial class Procedure : Method
-{
-	public string Schema              { get; set; }
-	public string ProcedureName       { get; set; }
-	public bool   IsFunction          { get; set; }
-	public bool   IsTableFunction     { get; set; }
-	public bool   IsAggregateFunction { get; set; }
-	public bool   IsDefaultSchema     { get; set; }
-	public bool   IsLoaded            { get; set; }
-
-	public Table           ResultTable     { get; set; }
-	public Exception       ResultException { get; set; }
-	public List<Table>     SimilarTables   { get; set; }
-	public List<Parameter> ProcParameters  { get; set; }
-}
-
-public class Parameter
-{
-	public string   SchemaName    { get; set; }
-	public string   SchemaType    { get; set; }
-	public bool     IsIn          { get; set; }
-	public bool     IsOut         { get; set; }
-	public bool     IsResult      { get; set; }
-	public long?    Size          { get; set; }
-
-	public string   ParameterName { get; set; }
-	public string   ParameterType { get; set; }
-	public bool     IsNullable    { get; set; }
-	public Type     SystemType    { get; set; }
-	public string   DataType      { get; set; }
-
-	public ModelType Type => new ModelType(ParameterType, !IsValueType(ParameterType), IsNullable);
-}
-
-private int _counter = 0;
-
-string ToValidNameDefault(string name, bool mayRemoveUnderscore)
-{
-	if (NormalizeNames)
-	{
-		if (mayRemoveUnderscore && name.Contains("_"))
-			name = SplitAndJoin(name, "", '_');
-		else if (NormalizeNamesWithoutUnderscores)
-			name = NormalizeFragment(name);
-	}
-
-	if (name.Contains("."))
-	{
-		name = SplitAndJoin(name, "", '.');
-	}
-
-	if (name.Length > 0 && char.IsDigit(name[0]))
-		name = "_" + name;
-
-	if (string.IsNullOrEmpty(name))
-		name = "_" + _counter++;
-
-	if (NormalizeNames)
-	{
-		name = char.ToUpper(name[0]) + name.Substring(1);
-	}
-
-	return name;
-}
-
-static string SplitAndJoin(string value, string join, params char[] split)
-{
-	var ss = value.Split(split, StringSplitOptions.RemoveEmptyEntries)
-		.Select(NormalizeFragment);
-
-	return string.Join(join, ss.ToArray());
-}
-
-static string NormalizeFragment(string s)
-{
-	return char.ToUpper(s[0]) + (s.Substring(1).All(char.IsUpper) ? s.Substring(1).ToLower() : s.Substring(1));
-}
-
-private string GetAssociationExtensionSinglularNameDefault(ForeignKey key)
-{
-	return ToSingular(key.Name);
-}
-
-private string GetAssociationExtensionPluralNameDefault(ForeignKey key)
-{
-	return ToPlural(ToSingular(key.Name));
-}
-
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/EditableObject.ttinclude b/src/Database.T4/LinqToDB.Templates/EditableObject.ttinclude
deleted file mode 100644
index 788f5ede41f190ba179e6dda286992b3a7761806..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/EditableObject.ttinclude
+++ /dev/null
@@ -1,259 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			EditableObjectImpl();
-			beforeGenerateModel();
-		};
-
-		SetPropertyValueAction += (obj,prop,val) =>
-		{
-			if (prop == "IsEditable")
-				obj.IsEditable = (bool)val;
-		};
-	}
-#>
-<#+
-void EditableObjectImpl()
-{
-	foreach (Property prop in GetTreeNodes(Model).OfType<Property>().Where(p => p.IsEditable).ToList())
-	{
-		SetPropertyValue(prop, "IsNotifying", true);
-
-		List<IClassMember> parentMembers;
-
-		MemberGroup gr = null;
-
-		if (prop.Parent is Class)
-		{
-			var parent = (Class)prop.Parent;
-			parentMembers = parent.Members;
-		}
-		else
-		{
-			var parent = (MemberGroup)prop.Parent;
-			parentMembers = parent.Members;
-
-			parent.IsCompact = false;
-		}
-
-		var name = prop.Name.Trim();
-		var type = prop.BuildType().Trim();
-
-		if (gr == null)
-		{
-			gr = new MemberGroup
-			{
-				Region          = name + " : " + type,
-				Members         = { prop },
-				IsPropertyGroup = true,
-			};
-
-			var index = parentMembers.IndexOf(prop);
-
-			parentMembers.RemoveAt(index);
-			parentMembers.Insert  (index, gr);
-		}
-
-		var originalField = new Field(() => type, "_original" + name)
-		{
-			AccessModifier       = AccessModifier.Private,
-			InsertBlankLineAfter = false,
-		};
-
-		gr.Members.Insert(0, originalField);
-
-		var currentField = new Field(() => type, " _current" + name)
-		{
-			AccessModifier       = AccessModifier.Private,
-			InsertBlankLineAfter = false,
-		};
-
-		if (prop.InitValue != null)
-		{
-			originalField.InitValue = prop.InitValue;
-			currentField.InitValue  = prop.InitValue;
-		}
-
-		gr.Members.Insert(0, currentField);
-
-		prop.Name        = "         " + name;
-		prop.TypeBuilder = () => " " + type;
-		prop.IsAuto      = false;
-
-		if (prop.HasGetter) prop.GetBodyBuilders.Add(() => new [] { "return " + currentField.Name.Trim() + ";" });
-		if (prop.HasSetter) prop.SetBodyBuilders.Add(() => new [] { currentField.Name.Trim() + " = value;" });
-
-		var ac = new Method  (() => "void", "Accept" + name + "Changes", null, () => new[] { string.Format("_original{0} = _current{0};", name) });
-		var rc = new Method  (() => "void", "Reject" + name + "Changes", null, () => new[] { string.Format("{0} = _original{0};", name) });
-		var id = new Property(() => "bool", "Is" + name + "Dirty")
-			.InitGetter(() => new [] { string.Format(prop.IsDirtyText, "_current" + name, "_original" + name) });
-
-		gr.Members.Add(new MemberGroup
-		{
-			Region  = "EditableObject support",
-			Members = { ac, rc, id },
-		});
-
-		prop.Parent.SetTree();
-	}
-
-	foreach (Class cl in GetTreeNodes(Model).OfType<Class>())
-	{
-		var props = GetTreeNodes(cl).OfType<Property>().Where(p => p.IsEditable).ToList();
-
-		if (props.Count > 0)
-		{
-			if (props.Any(p => p.IsEditable))
-			{
-				var ctor = GetTreeNodes(cl)
-					.OfType<Method>()
-					.FirstOrDefault(m => m.Name == cl.Name && m.ParameterBuilders.Count == 0);
-
-				if (ctor == null)
-				{
-					ctor = new Method(null, cl.Name);
-					cl.Members.Insert(0, ctor);
-				}
-
-				ctor.BodyBuilders.Add(() => new [] { "AcceptChanges();" });
-			}
-
-			var maxLen = props.Max(p => p.Name.Trim().Length);
-
-			var ac = new Method(() => "void", "AcceptChanges") { IsVirtual = true };
-			var rc = new Method(() => "void", "RejectChanges") { IsVirtual = true };
-			var id = new Property(() => "bool", "IsDirty") { IsAuto = false, HasSetter = false, IsVirtual = true };
-
-			ac.BodyBuilders.Add(() => new []
-			{
-				"BeforeAcceptChanges();",
-				""
-			});
-			rc.BodyBuilders.Add(() => new []
-			{
-				"BeforeRejectChanges();",
-				""
-			});
-			id.GetBodyBuilders.Add(() => new [] { "return" });
-
-			foreach (var p in props)
-			{
-				var name = p.Name.Trim();
-
-				ac.BodyBuilders.Add(() => new [] { string.Format("Accept{0}Changes();", name) });
-				rc.BodyBuilders.Add(() => new [] { string.Format("Reject{0}Changes();", name) });
-				id.GetBodyBuilders.Add(() => new [] { string.Format("\tIs{0}Dirty{1} ||", name, LenDiff(maxLen, name)) });
-			}
-
-			ac.BodyBuilders.Add(() => new[]
-			{
-				"",
-				"AfterAcceptChanges();"
-			});
-			rc.BodyBuilders.Add(() => new[]
-			{
-				"",
-				"AfterRejectChanges();"
-			});
-			var getBody = id.BuildGetBody().ToArray();
-			getBody[getBody.Length - 1] = getBody[getBody.Length - 1].Trim(' ' , '|') + ";";
-			id.GetBodyBuilders.Clear();
-			id.GetBodyBuilders.Add(() => getBody);
-
-			cl.Members.Add(new MemberGroup
-			{
-				Region  = "EditableObject support",
-				Members =
-				{
-					new MemberGroup
-					{
-						IsCompact = true,
-						Members   =
-						{
-							new Method(() => "void", "BeforeAcceptChanges") { AccessModifier = AccessModifier.Partial },
-							new Method(() => "void", "AfterAcceptChanges")  { AccessModifier = AccessModifier.Partial },
-						}
-					},
-					ac,
-					new MemberGroup
-					{
-						IsCompact = true,
-						Members   =
-						{
-							new Method(() => "void", "BeforeRejectChanges") { AccessModifier = AccessModifier.Partial },
-							new Method(() => "void", "AfterRejectChanges")  { AccessModifier = AccessModifier.Partial },
-						}
-					},
-					rc,
-					id
-				},
-			});
-
-			if (!cl.Interfaces.Contains("IEditableObject"))
-			{
-				if (!Model.Usings.Contains("System.ComponentModel"))
-					Model.Usings.Add("System.ComponentModel");
-
-				cl.Interfaces.Add("IEditableObject");
-
-				cl.Members.Add(new MemberGroup
-				{
-					Region  = "IEditableObject support",
-					Members =
-					{
-						new MemberGroup
-						{
-							IsCompact = true,
-							Members   =
-							{
-								new Field   (() => "bool", "_isEditing") { AccessModifier = AccessModifier.Private },
-								new Property(() => "bool", " IsEditing").InitGetter(() => new [] { "_isEditing" }),
-							}
-						},
-						new MemberGroup
-						{
-							IsCompact = true,
-							Members   =
-							{
-								new Method(() => "void", "BeginEdit",  null, () => new[] { "AcceptChanges();", "_isEditing = true;"   }) { IsVirtual = true },
-								new Method(() => "void", "CancelEdit", null, () => new[] { "_isEditing = false;", "RejectChanges();", }) { IsVirtual = true },
-								new Method(() => "void", "EndEdit",    null, () => new[] { "_isEditing = false;", "AcceptChanges();", }) { IsVirtual = true },
-							}
-						},
-					}
-				});
-			}
-		}
-
-		cl.SetTree();
-	}
-}
-
-partial class Property
-{
-	public bool   IsEditable;
-	public string IsDirtyText = "{0} != {1}";
-}
-
-class EditableProperty : Property
-{
-	public EditableProperty()
-	{
-		IsEditable = true;
-	}
-
-	public EditableProperty(ModelType type, string name)
-		: base(() => type.ToTypeName(), name, null, null)
-	{
-		IsEditable = true;
-	}
-
-	public EditableProperty(string type, string name)
-		: base(() => type, name, null, null)
-	{
-		IsEditable = true;
-	}
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/Equatable.ttinclude b/src/Database.T4/LinqToDB.Templates/Equatable.ttinclude
deleted file mode 100644
index b518248b12e88876568f8f58f61382fad17c2b52..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/Equatable.ttinclude
+++ /dev/null
@@ -1,107 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			beforeGenerateModel();
-			EquatableImpl();
-		};
-	}
-#><#+
-
-static bool DefaultEquatable = true;
-
-string EqualityComparerFieldName = "_comparer";
-
-Func<Class, Property, bool> EqualityPropertiesFilter = EqualityPropertiesFilterDefault;
-
-void EquatableImpl()
-{
-	foreach (Class cl in GetTreeNodes(Model).OfType<Class>().Where(c => c.IsEquatable && !c.IsStatic))
-	{
-		var props = GetTreeNodes(cl).OfType<Property>().Where(p => EqualityPropertiesFilter(cl, p)).ToList();
-		if (props.Count > 0)
-		{
-			var className = cl.Name;
-
-			if (!cl.Interfaces.Contains($"IEquatable<{className}>"))
-			{
-				cl.Interfaces.Add($"IEquatable<{className}>");
-
-				if (!Model.Usings.Contains("LinqToDB.Tools.Comparers"))
-					Model.Usings.Add("LinqToDB.Tools.Comparers");
-
-				var comparerProperties = string.Join(", ", props.Select(p => $"c => c.{p.Name}"));
-
-				cl.Members.Add(new MemberGroup
-				{
-					Region  = "IEquatable support",
-					Members =
-					{
-						new MemberGroup
-						{
-							IsCompact = false,
-							Members   =
-							{
-								new Field(() => $"IEqualityComparer<{className}>", EqualityComparerFieldName)
-								{
-									InitValue      = $"ComparerBuilder.GetEqualityComparer<{className}>({comparerProperties})",
-									AccessModifier = AccessModifier.Private,
-									IsStatic       = true,
-									IsReadonly     = true
-								},
-
-								new Method(() => "bool", "Equals",
-									new Func<string>[]
-									{
-										() => $"{new ModelType(className, true, true).ToTypeName()} other"
-									},
-									() => new[]
-									{
-										$"return {EqualityComparerFieldName}.Equals(this, other{(EnableNullableReferenceTypes ? "!" : "")});"
-									}),
-
-								new Method(() => "int", "GetHashCode", null,
-									() => new[]
-									{
-										$"return {EqualityComparerFieldName}.GetHashCode(this);"
-									})
-									{
-										IsOverride = true
-									},
-
-								new Method(() => "bool", "Equals",
-									new Func<string>[]
-									{
-										() => new ModelType("object", true, true).ToTypeName() + " obj",
-									},
-									() => new[]
-									{
-										$"if (!(obj is {className} other))", "\treturn false;", string.Empty,
-										"// use IEquatable implementation",
-										"return Equals(other);"
-									})
-									{
-										IsOverride = true
-									}
-							}
-						}
-					}
-				});
-			}
-		}
-
-		cl.SetTree();
-	}
-}
-
-partial class Class
-{
-	public bool IsEquatable = DefaultEquatable;
-}
-
-static bool EqualityPropertiesFilterDefault(Class cl, Property prop)
-{
-	return cl is Table && prop is Column col && col.IsPrimaryKey;
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/Humanizer.ttinclude b/src/Database.T4/LinqToDB.Templates/Humanizer.ttinclude
deleted file mode 100644
index 17be0916cc74e01a29558a7cd6013fe567aa1409..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/Humanizer.ttinclude
+++ /dev/null
@@ -1,15 +0,0 @@
-<#
-/*
-To use this extension you should:
-1) Reference Humanizer NuGet package into your project
-2) Include Humanizer.ttinclude
-3) Reference assembly like <_#@ assembly name="$(SolutionDir)\packages\Humanizer.Core.2.2.0\lib\netstandard1.0\Humanizer.dll" #_>
-*/
-#>
-<#@ import namespace="Humanizer" #>
-<#
-	NormalizeNames = true;
-	ToPlural       = s => s.Pluralize  (inputIsKnownToBeSingular: false);
-	ToSingular     = s => s.Singularize(inputIsKnownToBePlural:   false);
-	ToValidName    = (s, r) => s.Pascalize();
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.SqlTypes.Tools.ttinclude b/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.SqlTypes.Tools.ttinclude
deleted file mode 100644
index 05a8e66ec1169fb6519f94ac9ddb65e45e26cb44..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.SqlTypes.Tools.ttinclude
+++ /dev/null
@@ -1,3 +0,0 @@
-<#@ assembly name="$(LinqToDBT4SqlServerToolsDirectory)Microsoft.SqlServer.Types.dll" #>
-<#@ include file="LinqToDB.Tools.ttinclude" #>
-<#@ include file="LinqToDB.SqlServer.SqlTypes.ttinclude" #>
diff --git a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.Tools.ttinclude b/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.Tools.ttinclude
deleted file mode 100644
index fc678e10b2c02405a263e5e11578a0cb1bbb9b62..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.Tools.ttinclude
+++ /dev/null
@@ -1,2 +0,0 @@
-<#@ include file="LinqToDB.Tools.ttinclude" #>
-<#@ include file="LinqToDB.SqlServer.ttinclude" #>
diff --git a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.ttinclude b/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.ttinclude
deleted file mode 100644
index d013043a2cace4a499b4ddfb04ae56096576a7e8..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/LinqToDB.SqlServer.ttinclude
+++ /dev/null
@@ -1,106 +0,0 @@
-<#@ include file="LinqToDB.ttinclude"                  #>
-<#@ import namespace="LinqToDB.DataProvider.SqlServer" #>
-<#
-	{
-		GenerateProcedureDbType = p => p.DataType == "Structured" && p.SchemaType != null;
-
-		var afterGenerateLinqToDBModel = AfterGenerateLinqToDBModel;
-		AfterGenerateLinqToDBModel = () =>
-		{
-			afterGenerateLinqToDBModel();
-			DoGenerateSqlServerFreeText();
-		};
-
-		var buildColumnComparison = BuildColumnComparison;
-		BuildColumnComparison = (c, padding1, padding2, last) =>
-		{
-			if (c.BuildType() == "SqlHierarchyId")
-				return string.Format("\t(bool)(t.{0}{1} == {0}{3}){2}", c.MemberName, padding1, last ? ");" : " &&", last ? "" : padding2);
-			else
-				return buildColumnComparison(c, padding1, padding2, last);
-		};
-	}
-#>
-<#+
-bool GenerateSqlServerFreeText = false; // Defines whether to generate extensions for Free Text search, or not
-
-void DoGenerateSqlServerFreeText()
-{
-	if (!GenerateSqlServerFreeText)
-		return;
-
-	Model.Usings.Add("System.Collections.Generic");
-	Model.Usings.Add("System.Linq.Expressions");
-	Model.Usings.Add("System.Reflection");
-	Model.Usings.Add("LinqToDB");
-	Model.Usings.Add("LinqToDB.DataProvider.SqlServer");
-	Model.Usings.Add("LinqToDB.Extensions");
-
-	DataContextObject.Members.Add(
-		new MemberGroup
-		{
-			Region  = "FreeTextTable",
-			Members =
-			{
-				new Method(() => "IQueryable<SqlServerExtensions.FreeTextKey<TKey>>", "FreeTextTable",
-					new Func<string>[] { () => "ITable<TTable> table", () => $"Expression<Func<TTable,{ModelType.Create<object>(true).ToTypeName()}>> columns", () => "string search" },
-					() => new[]
-					{
-						"return Sql.Ext.SqlServer().FreeTextTable<TTable, TKey>(table, columns, search);"
-					})
-				{
-					GenericArguments = { "TTable", "TKey" }
-				},
-			}
-		}
-	);
-}
-
-LinqToDB.Data.DataConnection GetSqlServerConnection(
-	string connectionString,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	return LinqToDB.DataProvider.SqlServer.SqlServerTools.CreateDataConnection(connectionString, version, provider);
-}
-
-LinqToDB.Data.DataConnection GetSqlServerConnection(
-	string server,
-	string database,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	return GetSqlServerConnection(string.Format("Data Source={0};Database={1};Integrated Security=SSPI", server, database), version, provider);
-}
-
-LinqToDB.Data.DataConnection GetSqlServerConnection(string server, string database, string user, string password,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	return GetSqlServerConnection(string.Format("Server={0};Database={1};User Id={2};Password={3};", server, database, user, password), version, provider);
-}
-
-void LoadSqlServerMetadata(string connectionString,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	using (var dataConnection = GetSqlServerConnection(connectionString, version, provider))
-		LoadMetadata(dataConnection);
-}
-
-void LoadSqlServerMetadata(string server, string database,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	using (var dataConnection = GetSqlServerConnection(server, database, version, provider))
-		LoadMetadata(dataConnection);
-}
-
-void LoadSqlServerMetadata(string server, string database, string user, string password,
-	SqlServerVersion  version  = SqlServerVersion.v2008,
-	SqlServerProvider provider = SqlServerProvider.SystemDataSqlClient)
-{
-	using (var dataConnection = GetSqlServerConnection(server, database, user, password, version, provider))
-		LoadMetadata(dataConnection);
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/LinqToDB.Tools.ttinclude b/src/Database.T4/LinqToDB.Templates/LinqToDB.Tools.ttinclude
deleted file mode 100644
index d804bb85f737d248fb336c5a61e116e54d8dea57..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/LinqToDB.Tools.ttinclude
+++ /dev/null
@@ -1 +0,0 @@
-<#@ assembly name="$(LinqToDBT4ToolsDirectory)linq2db.dll" #>
diff --git a/src/Database.T4/LinqToDB.Templates/LinqToDB.ttinclude b/src/Database.T4/LinqToDB.Templates/LinqToDB.ttinclude
deleted file mode 100644
index 4ef00d74a9ff8718cabc6287f873a2bd90fc088a..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/LinqToDB.ttinclude
+++ /dev/null
@@ -1,1055 +0,0 @@
-<#@ assembly name="System.Data"        #>
-<#@ import namespace="System.Data"     #>
-<#@ import namespace="LinqToDB.Data"   #>
-<#@ import namespace="System.Text"     #>
-<#@ include file="DataModel.ttinclude" #>
-<#
-	if (BaseDataContextClass == null)
-		BaseDataContextClass = "LinqToDB.Data.DataConnection";
-#>
-<#+
-Action BeforeGenerateLinqToDBModel = () => {};
-Action AfterGenerateLinqToDBModel  = () => {};
-
-Func<Table,MemberBase> GenerateProviderSpecificTable = t => null;
-Func<Parameter, bool>  GenerateProcedureDbType       = p => false;
-
-bool   GenerateObsoleteAttributeForAliases = false;
-bool   GenerateFindExtensions              = true;
-bool   IsCompactColumns                    = true;
-bool   IsCompactColumnAliases              = true;
-bool   GenerateDataTypes                   = false;
-bool?  GenerateLengthProperty              = null;
-bool?  GeneratePrecisionProperty           = null;
-bool?  GenerateScaleProperty               = null;
-bool   GenerateDbTypes                     = false;
-bool   GenerateSchemaAsType                = false;
-bool   GenerateViews                       = true;
-bool   GenerateProcedureResultAsList       = false;
-bool   GenerateProceduresOnTypedContext    = true;
-bool   PrefixTableMappingWithSchema        = true;
-bool   PrefixTableMappingForDefaultSchema  = false;
-string SchemaNameSuffix                    = "Schema";
-string SchemaDataContextTypeName           = "DataContext";
-
-Dictionary<string,string> SchemaNameMapping = new Dictionary<string,string>();
-
-Func<string,string,IEnumerable<Method>> GetConstructors =  (conf, name) => GetConstructorsImpl(conf, name);
-
-Func<Column, string, string, bool, string> BuildColumnComparison = (c, padding1, padding2, last) =>
-{
-	return string.Format("\tt.{0}{1} == {0}{3}{2}", c.MemberName, padding1, last ? ");" : " &&", last ? "" : padding2);
-};
-
-static IEnumerable<Method> GetConstructorsImpl(string defaultConfiguration, string name)
-{
-	if (defaultConfiguration == null)
-		yield return new Method((Func<string>)null, name);
-	else
-		yield return new Method(null, name) { AfterSignature = { ": base(\"" + defaultConfiguration + "\")" } };
-	yield return new Method(null, name, new Func<string>[] { () => "string configuration" }) { AfterSignature = { ": base(configuration)" } };
-}
-
-void GenerateTypesFromMetadata()
-{
-	BeforeGenerateLinqToDBModel();
-
-	Model.Usings.Add("LinqToDB");
-	Model.Usings.Add("LinqToDB.Mapping");
-
-	if (NamespaceName == null)
-		NamespaceName = "DataModel";
-
-	string schemaName;
-
-	var schemas =
-	(
-		from t in Tables.Values
-		where GenerateSchemaAsType && t.Schema != null && !t.TableSchema.IsDefaultSchema
-		group t by t.Schema into gr
-		orderby gr.Key
-		let typeName = SchemaNameMapping.TryGetValue(gr.Key, out schemaName) ? schemaName : gr.Key
-		select new
-		{
-			Name            = gr.Key,
-			TypeName        = typeName + SchemaNameSuffix,
-			PropertyName    = typeName,
-			Props           = new MemberGroup { IsCompact = true },
-			Aliases         = new MemberGroup { IsCompact = true, Region = "Alias members" },
-			TableExtensions = new MemberGroup { Region = "Table Extensions" },
-			Type            = new Class(typeName + SchemaNameSuffix) { IsStatic = true },
-			Tables          = gr.ToList(),
-			DataContext     = new Class(SchemaDataContextTypeName),
-			Procedures      = new MemberGroup(),
-			Functions       = new MemberGroup(),
-			TableFunctions  = new MemberGroup { Region = "Table Functions" },
-		}
-	).ToDictionary(t => t.Name);
-
-	var procSchemas =
-	(
-		from p in Procedures.Values
-		where GenerateSchemaAsType && p.Schema != null && !p.IsDefaultSchema && !schemas.ContainsKey(p.Schema)
-		group p by p.Schema into gr
-		orderby gr.Key
-		let typeName = SchemaNameMapping.TryGetValue(gr.Key, out schemaName) ? schemaName : gr.Key
-		select new
-		{
-			Name            = gr.Key,
-			TypeName        = typeName + SchemaNameSuffix,
-			PropertyName    = typeName,
-			Props           = new MemberGroup { IsCompact = true },
-			Aliases         = new MemberGroup { IsCompact = true, Region = "Alias members" },
-			TableExtensions = new MemberGroup { Region = "Table Extensions" },
-			Type            = new Class(typeName + SchemaNameSuffix) { IsStatic = true },
-			Tables          = new List<Table>(),
-			DataContext     = new Class(SchemaDataContextTypeName),
-			Procedures      = new MemberGroup(),
-			Functions       = new MemberGroup(),
-			TableFunctions  = new MemberGroup { Region = "Table Functions" },
-		}
-	).ToDictionary(s => s.Name);
-
-	foreach(var schema in procSchemas)
-		schemas.Add(schema.Key, schema.Value);
-
-	var defProps           = new MemberGroup { IsCompact = true };
-	var defAliases         = new MemberGroup { IsCompact = true, Region = "Alias members" };
-	var defTableExtensions = new MemberGroup { };
-
-	if (schemas.Count > 0)
-	{
-		var body = new List<Func<IEnumerable<string>>>();
-
-		var schemaGroup   = new MemberGroup { Region = "Schemas" };
-		var schemaMembers = new MemberGroup { IsCompact = true   };
-
-		var maxLen1 = schemas.Values.Max(schema => schema.PropertyName.Trim().Length);
-		var maxLen2 = schemas.Values.Max(schema => schema.TypeName.    Trim().Length);
-
-		foreach (var schema in schemas.Values)
-		{
-			schemaMembers.Members.Add(new Property(true, () => schema.TypeName + "." + SchemaDataContextTypeName, schema.PropertyName));
-			body.Add(() => new string[] {
-				schema.PropertyName + LenDiff(maxLen1, schema.PropertyName) +
-				" = new " + schema.TypeName + "." + LenDiff(maxLen2, schema.TypeName) +
-				SchemaDataContextTypeName + "(this);"});
-		}
-
-		schemaGroup.Members.Add(schemaMembers);
-		schemaGroup.Members.Add(new Method(() => "void", "InitSchemas", new Func<string>[0], body.ToArray()));
-
-		DataContextObject.Members.Add(schemaGroup);
-	}
-
-	if (GenerateConstructors)
-	{
-		foreach (var c in GetConstructors(DefaultConfiguration, DataContextObject.Name))
-		{
-			if (c.BodyBuilders.Count > 0)
-				c.BodyBuilders.Add(() => new[] { "" });
-
-			if (schemas.Count > 0)
-				c.BodyBuilders.Add(() => new[] { "InitSchemas();" });
-
-			c.BodyBuilders.Add(() => new [] {"InitDataContext();", "InitMappingSchema();" });
-
-			DataContextObject.Members.Add(c);
-		}
-
-		DataContextObject.Members.Add(new MemberGroup
-		{
-			IsCompact = true,
-			Members   =
-			{
-				new Method(() => "void", "InitDataContext"  ) { AccessModifier = AccessModifier.Partial },
-				new Method(() => "void", "InitMappingSchema") { AccessModifier = AccessModifier.Partial }
-			}
-		});
-	}
-
-	if (Tables.Count > 0)
-		DataContextObject.Members.Insert(0, defProps);
-
-	foreach (var schema in schemas.Values)
-	{
-		schema.Type.Members.Add(schema.DataContext);
-		schema.DataContext.Members.Insert(0, schema.Props);
-
-		schema.DataContext.Members.Add(new Field (() => "IDataContext", "_dataContext") { AccessModifier = AccessModifier.Private, IsReadonly = true });
-		schema.DataContext.Members.Add(new Method(() => null, schema.DataContext.Name, new Func<string>[] { () => "IDataContext dataContext" }, () => new[] { "_dataContext = dataContext;" }));
-
-		foreach (var t in schema.Tables)
-		{
-			t.TypePrefix = schema.TypeName + ".";
-		}
-	}
-
-	var associationExtensions = new MemberGroup() {Region = "Associations"};
-
-	foreach (var t in Tables.Values.OrderBy(tbl => tbl.IsProviderSpecific).ThenBy(tbl => tbl.TypeName))
-	{
-		Action<Class> addType     = tp => Model.Types.Add(tp);
-		var props                 = defProps;
-		var aliases               = defAliases;
-		var tableExtensions       = defTableExtensions;
-
-		if (t.IsView && !GenerateViews) {
-			continue;
-		}
-
-		var schema = t.Schema != null && schemas.ContainsKey(t.Schema) ? schemas[t.Schema] : null;
-
-		if (schema != null)
-		{
-			var si = schemas[t.Schema];
-
-			addType         = tp => si.Type.Members.Add(tp);
-			props           = si.Props;
-			aliases         = si.Aliases;
-			tableExtensions = si.TableExtensions;
-		}
-
-		MemberBase dcProp = t.IsProviderSpecific ?
-			GenerateProviderSpecificTable(t) :
-			new Property(
-				() => string.Format("ITable<{0}>", t.TypeName),
-				t.DataContextPropertyName,
-				() => new[] { string.Format((schema == null ? "this" : "_dataContext") + ".GetTable<{0}>()", t.TypeName) },
-				null);
-
-		if (dcProp == null) continue;
-
-		t.DataContextProperty = dcProp;
-
-		props.Members.Add(dcProp);
-
-		Property aProp = null;
-
-		if (t.AliasPropertyName != null && t.AliasPropertyName != t.DataContextPropertyName)
-		{
-			aProp = new Property(
-				() => string.Format("ITable<{0}>", t.TypeName),
-				t.AliasPropertyName,
-				() => new[] { t.DataContextPropertyName },
-				null);
-
-			if (GenerateObsoleteAttributeForAliases)
-				aProp.Attributes.Add(new Attribute("Obsolete", ToStringLiteral("Use " + t.DataContextPropertyName + " instead.")));
-
-			aliases.Members.Add(aProp);
-		}
-
-		var tableAttrs = new List<string>();
-
-		if (ServerName   != null) tableAttrs.Add("Server="    + ToStringLiteral(ServerName));
-		if (DatabaseName != null) tableAttrs.Add("Database="  + ToStringLiteral(DatabaseName));
-		if (t.Schema     != null) tableAttrs.Add("Schema="    + ToStringLiteral(t.Schema));
-
-		tableAttrs.Add((tableAttrs.Count == 0 ? "" : "Name=") + ToStringLiteral(t.TableName));
-
-		if (t.IsView)
-			tableAttrs.Add("IsView=true");
-
-		t.Attributes.Add(new Attribute("Table", tableAttrs.ToArray()) { IsSeparated = true } );
-
-		var comments = new List<string>();
-
-		if (!string.IsNullOrWhiteSpace(t.Description))
-		{
-			comments.Add("/ <summary>");
-			foreach (var line in t.Description.Split('\n'))
-				comments.Add("/ " + line.TrimEnd());
-			comments.Add("/ </summary>");
-		}
-
-		if (comments.Count > 0)
-		{
-			t.     Comment.AddRange(comments);
-			dcProp.Comment.AddRange(comments);
-
-			if (aProp != null)
-				aProp.Comment.AddRange(comments);
-		}
-
-		var columns        = new MemberGroup { IsCompact = IsCompactColumns };
-		var columnAliases  = new MemberGroup { IsCompact = IsCompactColumnAliases, Region = "Alias members" };
-		var nPKs           = t.Columns.Values.Count(c => c.IsPrimaryKey);
-		var allNullable    = t.Columns.Values.All  (c => c.IsNullable || c.IsIdentity);
-		var nameMaxLen     = t.Columns.Values.Max  (c => (int?)(c.MemberName == c.ColumnName
-			? 0
-			: ToStringLiteral(c.ColumnName).Length)) ?? 0;
-		var dbTypeMaxLen   = t.Columns.Values.Max  (c => (int?)(c.ColumnType.Length)) ?? 0;
-		var dataTypeMaxLen = t.Columns.Values.Where(c => c.DataType != null).Max  (c => (int?)(c.DataType.Length)) ?? 0;
-		var dataTypePrefix = t.Columns.Values.Any  (c => c.MemberName == "DataType") ? "LinqToDB." : "";
-
-		foreach (var c in t.Columns.Values)
-		{
-			// Column.
-			//
-			var ca = new Attribute("Column");
-			var canBeReplaced = true;
-
-			if (c.MemberName != c.ColumnName)
-			{
-				var columnNameInAttr = ToStringLiteral(c.ColumnName);
-
-				var space = new string(' ', nameMaxLen - columnNameInAttr.Length);
-
-				ca.Parameters.Add(columnNameInAttr + space);
-				canBeReplaced = false;
-			}
-			else if (nameMaxLen > 0)
-			{
-				ca.Parameters.Add(new string(' ', nameMaxLen));
-				canBeReplaced = false;
-			}
-
-			if (GenerateDbTypes)
-			{
-				var space = new string(' ', dbTypeMaxLen - c.ColumnType.Length);
-
-				ca.Parameters.Add("DbType=" + ToStringLiteral(c.ColumnType) + space);
-				canBeReplaced = false;
-			}
-
-			if (GenerateDataTypes)
-			{
-				var space = new string(' ', dataTypeMaxLen - c.DataType.Length);
-				ca.Parameters.Add("DataType=" + dataTypePrefix + c.DataType + space);
-				canBeReplaced = false;
-			}
-
-			if (GenerateDataTypes && !GenerateLengthProperty.HasValue || GenerateLengthProperty == true)
-			{
-				if (c.Length    != null) ca.Parameters.Add("Length="    + (c.Length == int.MaxValue ? "int.MaxValue" : c.Length.ToString()));
-				canBeReplaced = false;
-			}
-
-			if (GenerateDataTypes && !GeneratePrecisionProperty.HasValue || GeneratePrecisionProperty == true)
-			{
-				if (c.Precision != null) ca.Parameters.Add("Precision=" + c.Precision);
-				canBeReplaced = false;
-			}
-
-			if (GenerateDataTypes && !GenerateScaleProperty.HasValue || GenerateScaleProperty == true)
-			{
-				if (c.Scale     != null) ca.Parameters.Add("Scale=" + c.Scale);
-				canBeReplaced = false;
-			}
-
-			if (c.SkipOnInsert && !c.IsIdentity)
-			{
-				ca.Parameters.Add("SkipOnInsert=true");
-				canBeReplaced = false;
-			}
-
-			if (c.SkipOnUpdate && !c.IsIdentity)
-			{
-				ca.Parameters.Add("SkipOnUpdate=true");
-				canBeReplaced = false;
-			}
-
-			if (c.IsDiscriminator)
-			{
-				ca.Parameters.Add("IsDiscriminator=true");
-				canBeReplaced = false;
-			}
-
-			c.Attributes.Insert(0, ca);
-
-			// PK.
-			//
-			if (c.IsPrimaryKey)
-			{
-				var pka = new Attribute("PrimaryKey");
-
-				if (nPKs > 1)
-					pka.Parameters.Add(c.PrimaryKeyOrder.ToString());
-
-				if (canBeReplaced)
-					c.Attributes.Remove(ca);
-
-				c.Attributes.Add(pka);
-
-				canBeReplaced = false;
-			}
-
-			// Identity.
-			//
-			if (c.IsIdentity)
-			{
-				var ida = new Attribute("Identity");
-
-				if (canBeReplaced)
-					c.Attributes.Remove(ca);
-
-				c.Attributes.Add(ida);
-
-				canBeReplaced = false;
-			}
-
-			// Nullable.
-			//
-			if (c.IsNullable)
-				c.Attributes.Add(new Attribute((allNullable ? "" : "   ") + "Nullable"));
-			else if (!c.IsIdentity)
-				c.Attributes.Add(new Attribute("NotNull"));
-
-			var columnComments = new List<string>();
-
-			if (!string.IsNullOrWhiteSpace(c.Description))
-			{
-				columnComments.Add("/ <summary>");
-				foreach (var line in c.Description.Split('\n'))
-					columnComments.Add("/ " + line.TrimEnd());
-				columnComments.Add("/ </summary>");
-			}
-
-			if (columnComments.Count > 0)
-				c.Comment.AddRange(columnComments);
-
-			// End line comment.
-			//
-			c.EndLineComment = c.ColumnType;
-
-			SetPropertyValue(c, "IsNotifying", true);
-			SetPropertyValue(c, "IsEditable",  true);
-
-			columns.Members.Add(c);
-
-			// Alias.
-			//
-			if (c.AliasName != null && c.AliasName != c.MemberName)
-			{
-				var caProp = new Property(
-					c.TypeBuilder,
-					c.AliasName,
-					() => new[] { c.MemberName },
-					() => new[] { c.MemberName + " = value;"});
-
-				caProp.Comment.AddRange(columnComments);
-
-				if (GenerateObsoleteAttributeForAliases)
-					caProp.Attributes.Add(new Attribute("Obsolete", ToStringLiteral("Use " + c.MemberName + " instead.")));
-
-				caProp.Attributes.Add(new Attribute("ColumnAlias" , ToStringLiteral(c.MemberName)));
-
-				columnAliases.Members.Add(caProp);
-			}
-		}
-
-		t.Members.Add(columns);
-
-		if (columnAliases.Members.Count > 0)
-			t.Members.Add(columnAliases);
-
-		if (GenerateAssociations || GenerateAssociationExtensions)
-		{
-			var keys = t.ForeignKeys.Values.ToList();
-
-			if (!GenerateBackReferences)
-				keys = keys.Where(k => k.BackReference != null).ToList();
-
-			if (keys.Count > 0)
-			{
-				var associations          = new MemberGroup { Region = "Associations" };
-				var extensionAssociations = new MemberGroup { Region = t.Name + " Associations"};
-
-				foreach (var key in keys.OrderBy(k => k.MemberName))
-				{
-					key.Comment.Add("/ <summary>");
-					key.Comment.Add("/ " + key.KeyName);
-					key.Comment.Add("/ </summary>");
-
-					if (key.AssociationType == AssociationType.OneToMany)
-						key.TypeBuilder = () => string.Format(OneToManyAssociationType, key.OtherTable.TypePrefix + key.OtherTable.TypeName);
-					else
-						key.TypeBuilder = () => new ModelType(key.OtherTable.TypePrefix + key.OtherTable.TypeName, true, key.CanBeNull).ToTypeName();
-
-					var aa = new Attribute("Association");
-
-					aa.Parameters.Add("ThisKey="   + ToStringLiteral(string.Join(", ", (from c in key.ThisColumns  select c.MemberName).ToArray())));
-					aa.Parameters.Add("OtherKey="  + ToStringLiteral(string.Join(", ", (from c in key.OtherColumns select c.MemberName).ToArray())));
-					aa.Parameters.Add("CanBeNull=" + (key.CanBeNull ? "true" : "false"));
-
-					switch (key.AssociationType)
-					{
-						case AssociationType.OneToOne  : aa.Parameters.Add("Relationship=Relationship.OneToOne");  break;
-						case AssociationType.OneToMany : aa.Parameters.Add("Relationship=Relationship.OneToMany"); break;
-						case AssociationType.ManyToOne : aa.Parameters.Add("Relationship=Relationship.ManyToOne"); break;
-					}
-
-					if (key.BackReference != null)
-					{
-						if (!string.IsNullOrEmpty(key.KeyName))
-							aa.Parameters.Add("KeyName=" + ToStringLiteral(key.KeyName));
-						if (GenerateBackReferences && !string.IsNullOrEmpty(key.BackReference.MemberName))
-							aa.Parameters.Add("BackReferenceName=" + ToStringLiteral(key.BackReference.MemberName));
-					}
-					else
-					{
-						aa.Parameters.Add("IsBackReference=true");
-					}
-
-					key.Attributes.Add(aa);
-
-					SetPropertyValue(key, "IsNotifying", true);
-					SetPropertyValue(key, "IsEditable",  true);
-
-					associations.Members.Add(key);
-
-					var extension = new Method(() => string.Format("IQueryable<{0}>", key.OtherTable.TypePrefix + key.OtherTable.TypeName), GetAssociationExtensionPluralName(key));
-					extension.Name = GetAssociationExtensionPluralName(key);
-
-					extension.ParameterBuilders.Add(() => string.Format("this {0}{1} obj", t.TypePrefix, t.TypeName));
-
-					extension.ParameterBuilders.Add(() => "IDataContext db");
-					extension.Attributes.Add(aa);
-					extension.IsStatic = true;
-
-					extension.Comment.Add("/ <summary>");
-					extension.Comment.Add("/ " + key.KeyName);
-					extension.Comment.Add("/ </summary>");
-
-					Func<string> builder = () =>
-					{
-						var sb = new StringBuilder();
-						sb
-							.Append("return db.GetTable<")
-							.Append(key.OtherTable.TypePrefix + key.OtherTable.TypeName)
-							.Append(">().Where(c => ");
-						for (var i = 0; i < key.OtherColumns.Count; i++)
-						{
-							sb.Append("c.")
-								.Append(key.OtherColumns[i].MemberName)
-								.Append(" == obj.")
-								.Append(key.ThisColumns[i].MemberName)
-								.Append(" && ");
-						}
-						sb.Length -= 4;
-						sb.Append(");");
-
-						return sb.ToString();
-					};
-
-					extension.BodyBuilders.Add(() => new[] { builder() });
-
-					extensionAssociations.Members.Add(extension);
-
-					if (key.AssociationType != AssociationType.OneToMany)
-					{
-						var single = new Method(() => t.TypePrefix + t.TypeName, GetAssociationExtensionSinglularName(key));
-
-						single.ParameterBuilders.Add(() => string.Format("this {0}{1} obj", key.OtherTable.TypePrefix, key.OtherTable.TypeName));
-
-						single.ParameterBuilders.Add(() => "IDataContext db");
-						single.Attributes.Add(aa);
-						single.IsStatic = true;
-
-						single.Comment.Add("/ <summary>");
-						single.Comment.Add("/ " + key.KeyName);
-						single.Comment.Add("/ </summary>");
-
-						Func<string> builderSingle = () =>
-						{
-							var sb = new StringBuilder();
-							sb
-								.Append("return db.GetTable<")
-								.Append(t.TypePrefix + t.TypeName)
-								.Append(">().Where(c => ");
-							for (var i = 0; i < key.OtherColumns.Count; i++)
-							{
-								sb.Append("c.")
-									.Append(key.ThisColumns[i].MemberName)
-									.Append(" == obj.")
-									.Append(key.OtherColumns[i].MemberName)
-									.Append(" && ");
-							}
-							sb.Length -= 4;
-							sb.Append(");");
-
-							return sb.ToString();
-						};
-
-						single.BodyBuilders.Add(() =>
-						{
-							var sb = new StringBuilder(builderSingle());
-							sb.Length -= 1;
-
-							if (key.CanBeNull)
-								sb.Append(".FirstOrDefault();");
-							else
-								sb.Append(".First();");
-
-							return new [] { sb.ToString() };
-						});
-
-						extensionAssociations.Members.Add(single);
-					}
-				}
-
-				if (GenerateAssociations)
-					t.Members.Add(associations);
-				if (GenerateAssociationExtensions)
-					associationExtensions.Members.Add(extensionAssociations);
-			}
-		}
-
-		if (GenerateFindExtensions && nPKs > 0)
-		{
-			var PKs         = t.Columns.Values.Where(c => c.IsPrimaryKey).ToList();
-			var maxNameLen1 = PKs.Max(c => (int?)c.MemberName.Length) ?? 0;
-			var maxNameLen2 = PKs.Take(nPKs - 1).Max(c => (int?)c.MemberName.Length) ?? 0;
-
-			tableExtensions.Members.Add(
-				new Method(
-					() => t.TypeName,
-					"Find",
-					new Func<string>[] { () => (string.Format("this ITable<{0}> table", t.TypeName)) }
-						.Union(PKs.Select(c => (Func<string>)(() => c.BuildType() + " " + c.MemberName))),
-					() => new[] { "return table.FirstOrDefault(t =>" }
-						.Union(PKs.SelectMany((c,i) =>
-						{
-							var ss = new List<string>();
-
-							if (c.Conditional != null)
-								ss.Add("#if " + c.Conditional);
-
-							ss.Add(BuildColumnComparison(c, LenDiff(maxNameLen1, c.MemberName), LenDiff(maxNameLen2, c.MemberName), i == nPKs - 1));
-
-							if (c.Conditional != null)
-							{
-								if (ss[1].EndsWith(");"))
-								{
-									ss[1] = ss[1].Substring(0, ss[1].Length - 2);
-									ss.Add("#endif");
-									ss.Add("\t\t);");
-								}
-								else
-								{
-									ss.Add("#endif");
-								}
-							}
-
-							return ss;
-						})))
-				{
-					IsStatic = true
-				});
-		}
-
-		addType(t);
-
-		if (!string.IsNullOrWhiteSpace(t.AliasTypeName))
-		{
-			var aClass = new Class(t.AliasTypeName)
-			{
-				BaseClass = t.TypeName
-			};
-
-			if (comments.Count > 0)
-				aClass.Comment.AddRange(comments);
-
-			if (GenerateObsoleteAttributeForAliases)
-				aClass.Attributes.Add(new Attribute("Obsolete", ToStringLiteral("Use " + t.TypeName + " instead.")));
-
-			Model.Types.Add(aClass);
-		}
-	}
-
-	if (associationExtensions.Members.Count > 0)
-		defTableExtensions.Members.Add(associationExtensions);
-
-	if (defAliases.Members.Count > 0)
-		DataContextObject.Members.Add(defAliases);
-
-	foreach (var schema in schemas.Values)
-		if (schema.Aliases.Members.Count > 0)
-			schema.Type.Members.Add(defAliases);
-
-	if (Procedures.Count > 0)
-	{
-		Model.Usings.Add("System.Collections.Generic");
-		Model.Usings.Add("System.Data");
-		Model.Usings.Add("LinqToDB.Data");
-		Model.Usings.Add("LinqToDB.Common");
-
-		if (Procedures.Values.Any(p => p.IsTableFunction))
-			Model.Usings.Add("System.Reflection");
-
-		if (Procedures.Values.Any(p => p.IsAggregateFunction))
-			Model.Usings.Add("System.Linq.Expressions");
-
-		var procs = new MemberGroup();
-		var funcs = new MemberGroup();
-		var tabfs = new MemberGroup { Region = "Table Functions" };
-
-		var currentContext = DataContextObject;
-		foreach (var p in Procedures.Values.Where(
-			proc => proc.IsLoaded || proc.IsFunction && !proc.IsTableFunction ||
-			proc.IsTableFunction && proc.ResultException != null
-			))
-		{
-			Action<MemberGroup> addProcs = tp => procs.Members.Add(tp);
-			Action<MemberGroup> addFuncs = tp => funcs.Members.Add(tp);
-			Action<MemberGroup> addTabfs = tp => tabfs.Members.Add(tp);
-
-			var thisDataContext = "this";
-
-			var schema = p.Schema != null && schemas.ContainsKey(p.Schema) ? schemas[p.Schema] : null;
-
-			if (schema != null)
-			{
-				var si = schemas[p.Schema];
-
-				addProcs        = tp => si.Procedures.    Members.Add(tp);
-				addFuncs        = tp => si.Functions.     Members.Add(tp);
-				addTabfs        = tp => si.TableFunctions.Members.Add(tp);
-				thisDataContext = "_dataContext";
-			}
-
-			var proc = new MemberGroup { Region = p.Name };
-
-			if (!p.IsFunction)          addProcs(proc);
-			else if (p.IsTableFunction) addTabfs(proc);
-			else                        addFuncs(proc);
-
-			if (p.ResultException != null)
-			{
-				proc.Errors.Add(p.ResultException.Message);
-				continue;
-			}
-
-			proc.Members.Add(p);
-
-			if (p.IsTableFunction)
-			{
-				var tableAttrs = new List<string>();
-
-				if (ServerName   != null) tableAttrs.Add("Server="   + ToStringLiteral(ServerName));
-				if (DatabaseName != null) tableAttrs.Add("Database=" + ToStringLiteral(DatabaseName));
-				if (p.Schema     != null) tableAttrs.Add("Schema="   + ToStringLiteral(p.Schema));
-
-				tableAttrs.Add("Name=" + ToStringLiteral(p.ProcedureName));
-
-				p.Attributes.Add(new Attribute("Sql.TableFunction", tableAttrs.ToArray()));
-
-				p.TypeBuilder = () => "ITable<" + p.ResultTable.TypeName + ">";
-			}
-			else if (p.IsAggregateFunction)
-			{
-				p.IsStatic = true;
-				p.TypeBuilder = () =>
-				{
-					var resultParam = p.ProcParameters.Single(pr => pr.IsResult);
-					return resultParam.Type.ToTypeName();
-				};
-				var paramCount = p.ProcParameters.Count(pr => !pr.IsResult);
-				p.Attributes.Add(new Attribute("Sql.Function", "Name=" + ToStringLiteral((p.Schema != null ? p.Schema + "." : null) + p.ProcedureName), "ServerSideOnly=true, IsAggregate = true" + (paramCount > 0 ? (", ArgIndices = new[] { " + string.Join(", ", Enumerable.Range(0, p.ProcParameters.Count(pr => !pr.IsResult))) + " }") : null)));
-
-				if (p.IsDefaultSchema || !GenerateSchemaAsType)
-					p.ParameterBuilders.Add(() => "this IEnumerable<TSource> src");
-				else // otherwise function will be generated in nested class, which doesn't support extension methods
-					p.ParameterBuilders.Add(() => "IEnumerable<TSource> src");
-
-				foreach (var inp in p.ProcParameters.Where(pr => !pr.IsResult))
-					p.ParameterBuilders.Add(() => $"Expression<Func<TSource, {inp.Type.ToTypeName()}>> " + inp.ParameterName);
-
-				p.Name += "<TSource>";
-			}
-			else if (p.IsFunction)
-			{
-				p.IsStatic    = true;
-				p.TypeBuilder = () => p.ProcParameters.Single(pr => pr.IsResult).Type.ToTypeName();
-				p.Attributes.Add(new Attribute("Sql.Function", "Name=" + ToStringLiteral((p.Schema != null ? p.Schema + "." : null)  + p.ProcedureName), "ServerSideOnly=true"));
-			}
-			else
-			{
-				p.IsStatic    = true;
-				p.TypeBuilder = () => p.ResultTable == null
-					? "int"
-					: GenerateProcedureResultAsList
-						? "List<" + p.ResultTable.TypeName + ">"
-						: "IEnumerable<" + p.ResultTable.TypeName + ">";
-
-				if (p.IsDefaultSchema || !GenerateSchemaAsType)
-					p.ParameterBuilders.Add(() => $"this { (GenerateProceduresOnTypedContext ? currentContext.Name : "DataConnection") } dataConnection");
-				else
-					p.ParameterBuilders.Add(() => $"{ (GenerateProceduresOnTypedContext ? currentContext.Name : "DataConnection") } dataConnection");
-			}
-
-			if (!p.IsAggregateFunction)
-				foreach (var pr in p.ProcParameters.Where(par => !par.IsResult || !p.IsFunction))
-					p.ParameterBuilders.Add(() => string.Format("{0}{1} {2}",
-						pr.IsOut || pr.IsResult ? pr.IsIn ? "ref " : "out " : "", pr.Type.ToTypeName(), pr.ParameterName));
-
-			if (p.IsTableFunction)
-			{
-				p.BodyBuilders.Add(() => new[]
-				{
-					string.Format("return " + thisDataContext + ".GetTable<{0}>(this, (MethodInfo)MethodBase.GetCurrentMethod()", p.ResultTable.TypeName)
-					+ (EnableNullableReferenceTypes ? "!" : "")
-					+ (p.ProcParameters.Count == 0 ? ");" : ",")
-				});
-
-				for (var idx = 0; idx < p.ProcParameters.Count; idx++)
-				{
-					var i = idx;
-					p.BodyBuilders.Add(() => new []{ "\t" + p.ProcParameters[i].ParameterName + (i + 1 == p.ProcParameters.Count ? ");" : ",") });
-				}
-			}
-			else if (p.IsFunction)
-			{
-				p.BodyBuilders.Add(() => new [] { "throw new InvalidOperationException();" });
-			}
-			else
-			{
-				var spName =
-					SqlBuilder.BuildTableName(
-						new System.Text.StringBuilder(),
-						ServerName   == null ? null : (string)SqlBuilder.ConvertInline(ServerName,   LinqToDB.SqlProvider.ConvertType.NameToServer),
-						DatabaseName == null ? null : (string)SqlBuilder.ConvertInline(DatabaseName, LinqToDB.SqlProvider.ConvertType.NameToDatabase),
-						p.Schema     == null ? null : (string)SqlBuilder.ConvertInline(p.Schema,     LinqToDB.SqlProvider.ConvertType.NameToSchema),
-						                              (string)SqlBuilder.ConvertInline(p.ProcedureName, LinqToDB.SqlProvider.ConvertType.NameToQueryTable)
-					).ToString();
-
-				spName = ToStringLiteral(spName);
-
-				var inputParameters      = p.ProcParameters.Where(pp => pp.IsIn).                            ToList();
-				var outputParameters     = p.ProcParameters.Where(pp => pp.IsOut || pp.IsResult).            ToList();
-				var inOrOutputParameters = p.ProcParameters.Where(pp => pp.IsIn  || pp.IsOut || pp.IsResult).ToList();
-
-				spName += inOrOutputParameters.Count == 0
-					? (p.ResultTable == null || !GenerateProcedureResultAsList ? ");" : ").ToList();")
-					: ",";
-
-				var retName = "ret";
-				var retNo   = 0;
-
-				while (p.ProcParameters.Any(pp => pp.ParameterName == retName))
-					retName = "ret" + ++retNo;
-
-				var hasOut = outputParameters.Any(pr => pr.IsOut || pr.IsResult);
-				var prefix = hasOut ? "var " + retName + " = " : "return ";
-
-				if (p.ResultTable == null)
-					p.BodyBuilders.Add(() => new [] { prefix + "dataConnection.ExecuteProc(" + spName });
-				else
-				{
-					if (p.ResultTable.Columns.Values.Any(c => c.IsDuplicateOrEmpty))
-					{
-						p.BodyBuilders.Add(() => new []
-						{
-							"var ms = dataConnection.MappingSchema;",
-							"",
-							prefix + "dataConnection.QueryProc(dataReader =>",
-							"\tnew " + p.ResultTable.TypeName,
-							"\t{"
-						});
-
-						var n          = 0;
-						var maxNameLen = p.ResultTable.Columns.Values.Max(c => (int?)c.MemberName .Length) ?? 0;
-						var maxTypeLen = p.ResultTable.Columns.Values.Max(c => (int?)c.BuildType().Length) ?? 0;
-
-						foreach (var c in p.ResultTable.Columns.Values)
-						{
-							p.BodyBuilders.Add(() => new [] {string.Format("\t\t{0}{1} = Converter.ChangeTypeTo<{2}>{3}(dataReader.GetValue({4}), ms),",
-								c.MemberName, LenDiff(maxNameLen, c.MemberName), c.BuildType(), LenDiff(maxTypeLen, c.BuildType()), n++) });
-						}
-
-						p.BodyBuilders.Add(() => new [] {"\t},", "\t" + spName });
-					}
-					else
-					{
-						p.BodyBuilders.Add(() => new [] { prefix + "dataConnection.QueryProc<" + p.ResultTable.TypeName + ">(" + spName });
-					}
-				}
-
-				var maxLenSchema = inputParameters.Max(pr => (int?)pr.SchemaName.   Length) ?? 0;
-				var maxLenParam  = inputParameters.Max(pr => (int?)pr.ParameterName.Length) ?? 0;
-				var maxLenType   = inputParameters.Max(pr => (int?)("DataType." + pr.DataType).Length) ?? 0;
-
-				for (var idx = 0; idx < inOrOutputParameters.Count; idx++)
-				{
-					var i = idx;
-					var pr = inOrOutputParameters[i];
-
-					p.BodyBuilders.Add(() =>
-					{
-						var str = string.Format(
-							!pr.IsIn && (pr.IsOut || pr.IsResult)
-								? "\tnew DataParameter({0}, null, {3}{4})"
-								: "\tnew DataParameter({0}, {1}{2}, {3}{4})" + (GenerateProcedureDbType(pr) ? "{{ DbType = {5} }}" : null),
-							ToStringLiteral(pr.SchemaName),
-							LenDiff(maxLenSchema, pr.SchemaName),
-							pr.ParameterName,
-							LenDiff(maxLenParam, pr.ParameterName),
-							"DataType." + pr.DataType,
-							ToStringLiteral(pr.SchemaType));
-
-						if (pr.IsOut || pr.IsResult)
-						{
-							str += LenDiff(maxLenType, "DataType." + pr.DataType);
-							str += " { Direction = " + (pr.IsIn ? "ParameterDirection.InputOutput" : (pr.IsResult ? "ParameterDirection.ReturnValue" : "ParameterDirection.Output"));
-
-							if (pr.Size != null && pr.Size.Value != 0)
-								str += ", Size = " + pr.Size.Value;
-
-							str += " }";
-						}
-
-						// we need to call ToList(), because otherwise output parameters will not be updated
-						// with values. See https://msdn.microsoft.com/en-us/library/ms971497#gazoutas_topic6
-						str += i + 1 == inOrOutputParameters.Count
-							? ((GenerateProcedureResultAsList || outputParameters.Count > 0) && p.ResultTable != null ? ").ToList();" : ");")
-							: ",";
-
-						return new [] { str };
-					});
-				}
-
-				if (hasOut)
-				{
-					maxLenSchema = outputParameters.Max(pr => (int?)pr.SchemaName.   Length    ) ?? 0;
-					maxLenParam  = outputParameters.Max(pr => (int?)pr.ParameterName.Length    ) ?? 0;
-					maxLenType   = outputParameters.Max(pr => (int?)pr.Type.ToTypeName().Length) ?? 0;
-
-					p.BodyBuilders.Add(() => new [] { string.Empty });
-
-					foreach (var pr in p.ProcParameters.Where(_ => _.IsOut || _.IsResult))
-					{
-						p.BodyBuilders.Add(() => new [] { string.Format("{0} {1}= Converter.ChangeTypeTo<{2}>{3}(((IDbDataParameter)dataConnection.Command.Parameters[{4}]).{5}Value);",
-							pr.ParameterName,
-							LenDiff(maxLenParam,  pr.ParameterName),
-							pr.Type.ToTypeName(),
-							LenDiff(maxLenType,   pr.Type.ToTypeName()),
-							ToStringLiteral(pr.SchemaName),
-							LenDiff(maxLenSchema, pr.SchemaName)) });
-					}
-
-					p.BodyBuilders.Add(() => new [] {"", "return " + retName + ";" });
-				}
-			}
-
-			if (p.ResultTable != null && p.ResultTable.DataContextPropertyName == null)
-			{
-				var columns = new MemberGroup { IsCompact = true };
-
-				foreach (var c in p.ResultTable.Columns.Values)
-				{
-					if (c.MemberName != c.ColumnName)
-						c.Attributes.Add(new Attribute("Column") { Parameters = { ToStringLiteral(c.ColumnName) } });
-					columns.Members.Add(c);
-				}
-
-				p.ResultTable.Members.Add(columns);
-				proc.Members.Add(p.ResultTable);
-			}
-		}
-
-		if (procs.Members.Count > 0)
-			Model.Types.Add(new Class(DataContextObject.Name + "StoredProcedures", procs) { IsStatic = true });
-
-		if (funcs.Members.Count > 0)
-			Model.Types.Add(new Class("SqlFunctions", funcs) { IsStatic = true });
-
-		if (tabfs.Members.Count > 0)
-			DataContextObject.Members.Add(tabfs);
-
-		MakeTypeMembersNamesUnique(DataContextObject, "InitDataContext", "InitMappingSchema");
-		MakeMembersNamesUnique(Model.Types, "Table");
-		foreach (var type in Model.Types.OfType<Class>())
-			MakeTypeMembersNamesUnique(type, exceptMethods: new [] { "FreeTextTable", "Find", "InitDataContext", "InitMappingSchema" });
-
-		foreach (var schema in schemas.Values)
-		{
-			if (schema.Procedures.Members.Count > 0)
-				schema.Type.Members.Add(new Class(DataContextObject.Name + "StoredProcedures", schema.Procedures) { IsStatic = true });
-
-			if (schema.Functions.Members.Count > 0)
-				schema.Type.Members.Add(new Class("SqlFunctions", schema.Functions) { IsStatic = true });
-
-			if (schema.TableFunctions.Members.Count > 0)
-				schema.DataContext.Members.Add(schema.TableFunctions);
-
-			MakeTypeMembersNamesUnique(schema.DataContext, "InitDataContext", "InitMappingSchema");
-			foreach (var type in schema.Type.Members.OfType<Class>())
-				MakeTypeMembersNamesUnique(type);
-		}
-	}
-
-	if (defTableExtensions.Members.Count > 0)
-	{
-		Model.Usings.Add("System.Linq");
-		var tableExtensions = new Class("TableExtensions", defTableExtensions) { IsStatic = true };
-		Model.Types.Add(tableExtensions);
-		MakeTypeMembersNamesUnique(tableExtensions, exceptMethods: new [] { "Find", "FreeTextTable" });
-	}
-
-	foreach (var schema in schemas.Values)
-	{
-		Model.Types.Add(schema.Type);
-
-		if (schema.TableExtensions.Members.Count > 0)
-		{
-			Model.Usings.Add("System.Linq");
-			schema.Type.Members.Add(schema.TableExtensions);
-		}
-	}
-
-	Tables.    Clear();
-	Procedures.Clear();
-
-	Model.SetTree();
-
-	AfterGenerateLinqToDBModel();
-}
-
-void MakeTypeMembersNamesUnique(Class type, string defaultName = "Member", params string[] exceptMethods)
-{
-	var reservedNames = new [] { type.Name };
-	if (exceptMethods != null && exceptMethods.Length > 0)
-		reservedNames = reservedNames.Concat(exceptMethods).ToArray();
-
-	MakeMembersNamesUnique(GetAllClassMembers(type.Members, exceptMethods), defaultName, reservedNames);
-}
-
-void MakeMembersNamesUnique(IEnumerable<IClassMember> members, string defaultName, params string[] reservedNames)
-{
-	LinqToDB.Common.Utils.MakeUniqueNames(
-		members,
-		reservedNames,
-		m => m is Table tbl ? (tbl.Schema != null && (PrefixTableMappingForDefaultSchema || !tbl.IsDefaultSchema) && PrefixTableMappingWithSchema ? tbl.Schema + "_" : null) + tbl.Name : (m is TypeBase t ? t.Name : ((MemberBase)m).Name),
-		(m, newName, _) =>
-		{
-			if (m is TypeBase t)
-				t.Name = newName;
-			else
-				((MemberBase)m).Name = newName;
-		},
-		defaultName);
-}
-
-IEnumerable<IClassMember> GetAllClassMembers(IEnumerable<IClassMember> members, params string[] exceptMethods)
-{
-	foreach (var member in members)
-	{
-		if (member is MemberGroup mg)
-			foreach (var m in GetAllClassMembers(mg.Members, exceptMethods))
-				yield return m;
-		// constructors don't have own type/flag
-		else if (member is Method method && (method.BuildType() == null || (exceptMethods != null && exceptMethods.Contains(method.Name))))
-			continue;
-		else
-			yield return member;
-	}
-}
-
-// left for backward compatibility
-string NormalizeStringName(string name)
-{
-	return ToStringLiteral(name);
-}
-
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/MultipleFiles.ttinclude b/src/Database.T4/LinqToDB.Templates/MultipleFiles.ttinclude
deleted file mode 100644
index 4b43ba0cb45ef6415572f3758f81c3cec9fc9c93..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/MultipleFiles.ttinclude
+++ /dev/null
@@ -1,70 +0,0 @@
-<#@ assembly name="System.Core"                   #>
-<#@ assembly name="EnvDTE"                        #>
-<#@ import namespace="System.Collections.Generic" #>
-<#@ import namespace="System.IO"                  #>
-<#@ import namespace="System.Linq"                #>
-<#@ import namespace="EnvDTE"                     #>
-<#+
-DTE _dte;
-DTE  DTE => _dte ?? (_dte = (DTE)((IServiceProvider)Host).GetService(typeof(DTE)));
-
-ProjectItem _templateProjectItem;
-ProjectItem  TemplateProjectItem => _templateProjectItem ?? (_templateProjectItem = DTE.Solution.FindProjectItem(Host.TemplateFile));
-
-readonly Dictionary<string,int> _fileNames = new Dictionary<string,int>();
-
-Func<string,string,bool> CompareContent = (s1,s2) => s1 == s2;
-
-void SaveOutput(string fileName, int fileType = 1)
-{
-	var dir        = Path.GetDirectoryName(Host.TemplateFile);
-	var output     = Path.Combine(dir, fileName);
-	var newContent = GenerationEnvironment.ToString();
-	var oldContent = File.Exists(output) ? File.ReadAllText(output) : "";
-
-	if (!CompareContent(newContent, oldContent))
-	{
-		if (DTE.SourceControl != null && DTE.SourceControl.IsItemUnderSCC(output) && !DTE.SourceControl.IsItemCheckedOut(output))
-			DTE.SourceControl.CheckOutItem(output);
-
-		File.WriteAllText(output, newContent);
-	}
-
-	GenerationEnvironment.Length = 0;
-
-	_fileNames.Add(output, fileType);
-}
-
-void SyncProject()
-{
-	var keepFileNames      = _fileNames.ToDictionary(f => f.Key);
-	var projectFiles       = new Dictionary<string,ProjectItem>();
-	var templateFileName   = TemplateProjectItem.FileNames[0];
-	var originalFilePrefix = Path.GetFileNameWithoutExtension(templateFileName) + ".";
-
-	foreach (ProjectItem projectItem in TemplateProjectItem.ProjectItems)
-	{
-		projectFiles.Add(projectItem.FileNames[0], projectItem);
-	}
-
-	foreach (var pair in projectFiles)
-	{
-		if (!keepFileNames.ContainsKey(pair.Key))
-			if (!(Path.GetFileNameWithoutExtension(pair.Key) + ".").StartsWith(originalFilePrefix))
-			//if (pair.Key != templateFileName)
-				pair.Value.Delete();
-	}
-
-	// Add missing files to the project.
-	//
-	foreach (var fileName in keepFileNames)
-	{
-		if (!projectFiles.ContainsKey(fileName.Value.Key))
-		if (File.Exists(fileName.Value.Key))
-		{
-			var newItem = TemplateProjectItem.ProjectItems.AddFromFile(fileName.Value.Key);
-			newItem.Properties.Item("BuildAction").Value = fileName.Value.Value;
-		}
-	}
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/NotifyDataErrorInfo.ttinclude b/src/Database.T4/LinqToDB.Templates/NotifyDataErrorInfo.ttinclude
deleted file mode 100644
index 6c298084e72e7d40874498e6a00a41a44572902c..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/NotifyDataErrorInfo.ttinclude
+++ /dev/null
@@ -1,133 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			beforeGenerateModel();
-			NotifyDataErrorInfoImpl();
-		};
-	}
-#>
-<#+
-void NotifyDataErrorInfoImpl()
-{
-	foreach (var prop in  GetTreeNodes(Model).OfType<Property>().Where(p => p.CustomValidation).ToList())
-	{
-		ITree p = prop.Parent;
-
-		while (!(p is Class) && p != null)
-			p = p.Parent;
-
-		if (p != null)
-		{
-			var cl = (Class)p;
-
-			if (!cl.Interfaces.Contains("INotifyDataErrorInfo"))
-			{
-				if (!Model.Usings.Contains("System.ComponentModel")) Model.Usings.Add("System.ComponentModel");
-				if (!Model.Usings.Contains("System.Collections"))    Model.Usings.Add("System.Collections");
-				if (!Model.Usings.Contains("System.Linq"))           Model.Usings.Add("System.Linq");
-
-				cl.Interfaces.Add("INotifyDataErrorInfo");
-
-				cl.Members.Add(new MemberGroup
-				{
-					Region  = "INotifyDataErrorInfo support",
-					Members =
-					{
-						new Event("EventHandler<DataErrorsChangedEventArgs>", "ErrorsChanged", true)
-						{
-							IsVirtual  = true,
-							Attributes = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } }
-						},
-						new Field(() => "Dictionary<string,List<string>>", "_validationErrors")
-						{
-							InitValue      = "new Dictionary<string,List<string>>()",
-							AccessModifier = AccessModifier.Private,
-							IsReadonly     = true,
-							Attributes     = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } }
-						},
-						new Method(() => "void", "AddError",
-							new Func<string>[]
-							{
-								() => "string propertyName",
-								() => "string error"
-							},
-							() => new[]
-							{
-								"List<string> errors;",
-								"",
-								"if (!_validationErrors.TryGetValue(propertyName, out errors))",
-								"{",
-									"\t_validationErrors[propertyName] = new List<string> { error };",
-								"}",
-								"else if (!errors.Contains(error))",
-								"{",
-									"\terrors.Add(error);",
-								"}",
-								"else",
-									"\treturn;",
-								"",
-								"OnErrorsChanged(propertyName);",
-							})
-						{
-							AccessModifier = AccessModifier.Public
-						},
-						new Method(() => "void", "RemoveError",
-							new Func<string>[]
-							{
-								() => "string propertyName",
-							},
-							() => new[]
-							{
-								"List<string> errors;",
-								"",
-								"if (_validationErrors.TryGetValue(propertyName, out errors) && errors.Count > 0)",
-								"{",
-									"\t_validationErrors.Clear();",
-									"\tOnErrorsChanged(propertyName);",
-								"}",
-							})
-						{
-							AccessModifier = AccessModifier.Public
-						},
-						new Method(() => "void", "OnErrorsChanged",
-							new Func<string>[]
-							{
-								() => "string propertyName",
-							},
-							() => new[]
-							{
-								"if (ErrorsChanged != null)",
-								"{",
-									"\tif (System.Windows.Application.Current.Dispatcher.CheckAccess())",
-										"\t\tErrorsChanged(this, new DataErrorsChangedEventArgs(propertyName));",
-									"\telse",
-										"\t\tSystem.Windows.Application.Current.Dispatcher.BeginInvoke(",
-											"\t\t\t(Action)(() => ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName))));",
-								"}",
-							})
-						{
-							AccessModifier = AccessModifier.Protected
-						},
-						new Method(() => ModelType.Create<System.Collections.IEnumerable>(true).ToTypeName(), "GetErrors",
-							new Func<string>[]
-							{
-								() => $"{ModelType.Create<string>(true).ToTypeName()} propertyName",
-							},
-							() => new[]
-							{
-								"List<string> errors;",
-								"return propertyName != null && _validationErrors.TryGetValue(propertyName, out errors) ? errors : null;",
-							})
-						{
-							AccessModifier = AccessModifier.Public
-						},
-						new Property(() => "bool", "HasErrors").InitGetter(() => new [] { "_validationErrors.Values.Any(e => e.Count > 0)" })
-					}
-				});
-			}
-		}
-	}
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/NotifyPropertyChanged.ttinclude b/src/Database.T4/LinqToDB.Templates/NotifyPropertyChanged.ttinclude
deleted file mode 100644
index b3ebd8b5d2ecb4aee73657bff639b08547640fe6..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/NotifyPropertyChanged.ttinclude
+++ /dev/null
@@ -1,344 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			beforeGenerateModel();
-			NotifyPropertyChangedImpl();
-		};
-
-		SetPropertyValueAction += (obj,prop,val) =>
-		{
-			if (prop == "IsNotifying")
-				obj.IsNotifying = (bool)val;
-		};
-	}
-#><#+
-public bool ImplementNotifyPropertyChanging;
-public bool SkipNotifyPropertyChangedImplementation = false;
-
-void NotifyPropertyChangedImpl()
-{
-	foreach (Property prop in GetTreeNodes(Model).OfType<Property>().Where(p => p.IsNotifying).ToList())
-	{
-		List<IClassMember> parentMembers;
-
-		MemberGroup gr = null;
-
-		if (prop.Parent is Class)
-		{
-			var parent = (Class)prop.Parent;
-			parentMembers = parent.Members;
-		}
-		else
-		{
-			var parent = (MemberGroup)prop.Parent;
-
-			parent.IsCompact = false;
-
-			parentMembers = parent.Members;
-
-			if (parent.IsPropertyGroup)
-				gr = parent;
-		}
-
-		var name = prop.Name.Trim();
-		var type = prop.BuildType().Trim();
-
-		if (gr == null)
-		{
-			gr = new MemberGroup
-			{
-				Region          = name + " : " + type,
-				Members         = { prop },
-				IsPropertyGroup = true,
-			};
-
-			var index = parentMembers.IndexOf(prop);
-
-			parentMembers.RemoveAt(index);
-			parentMembers.Insert  (index, gr);
-		}
-
-		gr.Conditional   = prop.Conditional;
-		prop.Conditional = null;
-
-		if (prop.IsAuto)
-		{
-			var field = new Field(() => type, "_" + ToCamelCase(name))
-			{
-				AccessModifier       = AccessModifier.Private,
-				InsertBlankLineAfter = false,
-			};
-
-			if (prop.InitValue != null)
-				field.InitValue = prop.InitValue;
-
-			gr.Members.Insert(0, field);
-
-			prop.Name        = " " + name;
-			prop.TypeBuilder = () => " " + type;
-			prop.IsAuto      = false;
-
-			if (prop.HasGetter) prop.GetBodyBuilders.Add(() => new [] { "return " + field.Name + ";" });
-			if (prop.HasSetter) prop.SetBodyBuilders.Add(() => new [] { field.Name + " = value;" });
-		}
-
-		var methods = new MemberGroup
-		{
-			Region  = "INotifyPropertyChanged support",
-			Members =
-			{
-				new Field(() => "const string", "NameOf" + name)
-				{
-					InitValue      = ToStringLiteral(name),
-					AccessModifier = AccessModifier.Public,
-				},
-				new Field(() => "PropertyChangedEventArgs", "_" + ToCamelCase(name) + "ChangedEventArgs")
-				{
-					InitValue      = "new PropertyChangedEventArgs(NameOf" + name + ")",
-					AccessModifier = AccessModifier.Private,
-					IsStatic       = true,
-					IsReadonly     = true,
-				},
-				new Method(() => "void", "On" + name + "Changed", null,
-					() => new[] { "OnPropertyChanged(_" + ToCamelCase(name) + "ChangedEventArgs);" })
-				{
-					AccessModifier = AccessModifier.Private
-				}
-			}
-		};
-
-		gr.Members.Add(methods);
-
-		if (prop.Dependents.Count == 0)
-			prop.Dependents.Add(name);
-
-		if (ImplementNotifyPropertyChanging)
-		{
-			gr.Members.Add(new MemberGroup
-			{
-				Region  = "INotifyPropertyChanging support",
-				Members =
-				{
-					new Field(() => "PropertyChangingEventArgs", "_" + ToCamelCase(name) + "ChangingEventArgs")
-					{
-						InitValue      = "new PropertyChangingEventArgs(NameOf" + name + ")",
-						AccessModifier = AccessModifier.Private,
-						IsStatic       = true,
-						IsReadonly     = true,
-					},
-					new Method(() => "void", "On" + name + "Changing", null,
-						() => new[] { "OnPropertyChanging(_" + ToCamelCase(name) + "ChangingEventArgs);" })
-					{
-						AccessModifier = AccessModifier.Private
-					}
-				}
-			});
-		}
-
-		if (prop.HasSetter)
-		{
-			var setBody = prop.BuildSetBody().Select(s => "\t" + s).ToArray();
-			prop.SetBodyBuilders.Clear();
-			prop.SetBodyBuilders.Add(() => setBody);
-
-			string getValue;
-
-			var getBody = prop.BuildGetBody().ToArray();
-			if (getBody.Length == 1 && getBody[0].StartsWith("return"))
-			{
-				getValue = getBody[0].Substring("return".Length).Trim(' ', '\t', ';');
-			}
-			else
-			{
-				getValue = name;
-			}
-
-			var insSpaces = setBody.Length > 1;
-			var n = 0;
-
-			prop.SetBodyBuilders.Insert(n++, () => new [] {"if (" + getValue + " != value)", "{" });
-
-			if (ImplementNotifyPropertyChanging)
-			{
-				foreach (var dp in prop.Dependents)
-					prop.SetBodyBuilders.Insert(n++, () => new [] { "\tOn" + dp + "Changing();" });
-				prop.SetBodyBuilders.Insert(n++, () => new [] { "" });
-			}
-
-			prop.SetBodyBuilders.Insert(n++, () => new [] { "\tBefore" + name + "Changed(value);" });
-
-			if (insSpaces)
-			{
-				prop.SetBodyBuilders.Insert(3, () => new [] { "" });
-				prop.SetBodyBuilders.Add(() => new [] { "" });
-			}
-
-			prop.SetBodyBuilders.Add(() => new [] { "\tAfter" + name + "Changed();" });
-			prop.SetBodyBuilders.Add(() => new [] { "" });
-
-			foreach (var dp in prop.Dependents)
-				prop.SetBodyBuilders.Add(() => new [] { "\tOn" + dp + "Changed();" });
-
-			prop.SetBodyBuilders.Add(() => new [] { "}" });
-
-			methods.Members.Insert(0, new MemberGroup
-			{
-				IsCompact = true,
-				Members   =
-				{
-					new Method(() => "void", "Before" + name + "Changed", new Func<string>[] { () => type + " newValue" }) { AccessModifier = AccessModifier.Partial },
-					new Method(() => "void", "After"  + name + "Changed") { AccessModifier = AccessModifier.Partial },
-				}
-			});
-		}
-
-		prop.Parent.SetTree();
-
-		ITree p = prop.Parent;
-
-		while (!(p is Class) && p != null)
-			p = p.Parent;
-
-		if (p != null)
-		{
-			var cl = (Class)p;
-
-			if (!SkipNotifyPropertyChangedImplementation && !cl.Interfaces.Contains("INotifyPropertyChanged"))
-			{
-				if (!Model.Usings.Contains("System.ComponentModel"))
-					Model.Usings.Add("System.ComponentModel");
-
-				cl.Interfaces.Add("INotifyPropertyChanged");
-
-				cl.Members.Add(new MemberGroup
-				{
-					Region  = "INotifyPropertyChanged support",
-					Members =
-					{
-						new Event("PropertyChangedEventHandler", "PropertyChanged", true)
-						{
-							IsVirtual  = true,
-							Attributes = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } }
-						},
-						new Method(() => "void", "OnPropertyChanged", new Func<string>[] { () => "string propertyName" }, () => OnPropertyChangedBody)
-						{
-							AccessModifier = AccessModifier.Protected
-						},
-						new Method(() => "void", "OnPropertyChanged", new Func<string>[] { () => "PropertyChangedEventArgs arg" }, () => OnPropertyChangedArgBody)
-						{
-							AccessModifier = AccessModifier.Protected
-						},
-					}
-				});
-			}
-
-			if (ImplementNotifyPropertyChanging && !cl.Interfaces.Contains("INotifyPropertyChanging"))
-			{
-				if (!Model.Usings.Contains("System.ComponentModel"))
-					Model.Usings.Add("System.ComponentModel");
-
-				cl.Interfaces.Add("INotifyPropertyChanging");
-
-				cl.Members.Add(new MemberGroup
-				{
-					Region  = "INotifyPropertyChanging support",
-					Members =
-					{
-						new Event("PropertyChangingEventHandler", "PropertyChanging", true)
-						{
-							IsVirtual  = true,
-							Attributes = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } }
-						},
-						new Method(() => "void", "OnPropertyChanging", new Func<string>[] { () => "string propertyName" }, () => OnPropertyChangingBody)
-						{
-							AccessModifier = AccessModifier.Protected
-						},
-						new Method(() => "void", "OnPropertyChanging", new Func<string>[] { () => "PropertyChangingEventArgs arg" }, () => OnPropertyChangingArgBody)
-						{
-							AccessModifier = AccessModifier.Protected
-						},
-					}
-				});
-			}
-		}
-	}
-}
-
-public string[] OnPropertyChangedBody = new[]
-{
-	"var propertyChanged = PropertyChanged;",
-	"",
-	"if (propertyChanged != null)",
-	"{",
-	"\tpropertyChanged(this, new PropertyChangedEventArgs(propertyName));",
-	"}",
-};
-
-public string[] OnPropertyChangedArgBody = new[]
-{
-	"var propertyChanged = PropertyChanged;",
-	"",
-	"if (propertyChanged != null)",
-	"{",
-	"\tpropertyChanged(this, arg);",
-	"}",
-};
-
-public string[] OnPropertyChangingBody = new[]
-{
-	"var propertyChanging = PropertyChanging;",
-	"",
-	"if (propertyChanging != null)",
-	"{",
-	"\tpropertyChanging(this, new PropertyChangingEventArgs(propertyName));",
-	"}",
-};
-
-public string[] OnPropertyChangingArgBody = new[]
-{
-	"var propertyChanging = PropertyChanging;",
-	"",
-	"if (propertyChanging != null)",
-	"{",
-	"\tpropertyChanging(this, arg);",
-	"}",
-};
-
-partial class Property
-{
-	public bool         IsNotifying;
-	public List<string> Dependents = new List<string>();
-}
-
-class NotifyingProperty : Property
-{
-	public NotifyingProperty()
-	{
-		IsNotifying = true;
-	}
-
-	public NotifyingProperty(ModelType type, string name, params string[] dependents)
-		: base(() => type.ToTypeName(), name, null, null)
-	{
-		IsNotifying = true;
-
-		if (dependents.Length == 0)
-			Dependents.Add(name);
-		else
-			Dependents.AddRange(dependents);
-	}
-
-	public NotifyingProperty(string type, string name, params string[] dependents)
-		: base(() => type, name, null, null)
-	{
-		IsNotifying = true;
-
-		if (dependents.Length == 0)
-			Dependents.Add(name);
-		else
-			Dependents.AddRange(dependents);
-	}
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/ObsoleteAttributes.ttinclude b/src/Database.T4/LinqToDB.Templates/ObsoleteAttributes.ttinclude
deleted file mode 100644
index b95b0d894120fb8d42eb07cf84319f9c2e92def8..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/ObsoleteAttributes.ttinclude
+++ /dev/null
@@ -1,100 +0,0 @@
-<#
-	{
-		var beforeGenerateLinqToDBModel = BeforeGenerateLinqToDBModel;
-		var afterGenerateLinqToDBModel  = AfterGenerateLinqToDBModel;
-
-		var obsoleteTables = new List<Tuple<string,string,string>>();
-
-		BeforeGenerateLinqToDBModel = () =>
-		{
-			beforeGenerateLinqToDBModel();
-
-			foreach (var table in Tables.Values)
-			{
-				var idx = table.Description.IndexOf("[Obsolete");
-
-				if (idx >= 0)
-				{
-					var idx2 = table.Description.IndexOf(']', idx);
-
-					if (idx2 > idx)
-					{
-						var text = table.Description.Substring(idx + 1, idx2 - idx - 1);
-						var attr = new Attribute(text);
-						var info = Tuple.Create(table.Schema, table.Name, text);
-
-						if (obsoleteTables.All(a => a != info))
-							obsoleteTables.Add(info);
-						table.Attributes.Add(attr);
-						table.Description = table.Description.Substring(0, idx) + table.Description.Substring(idx2 + 1);
-					}
-				}
-
-				foreach (var c in table.Columns.Values)
-				{
-					idx = c.Description.IndexOf("[Obsolete");
-
-					if (idx >= 0)
-					{
-						var idx2 = c.Description.IndexOf(']', idx);
-
-						if (idx2 > idx)
-						{
-							var attr = new Attribute(c.Description.Substring(idx + 1, idx2 - idx - 1));
-
-							c.Attributes.Add(attr);
-							c.Description = c.Description.Substring(0, idx) + c.Description.Substring(idx2 + 1);
-						}
-					}
-				}
-			}
-		};
-
-		AfterGenerateLinqToDBModel = () =>
-		{
-			foreach (var tableInfo in obsoleteTables)
-			{
-				var schema       = tableInfo.Item1;
-				var name         = tableInfo.Item2;
-				var text         = tableInfo.Item3;
-				var obsoleteAttr = new Attribute(text);
-
-				foreach (var cm in GetTreeNodes(Model)
-					.OfType<MemberBase>()
-					.Where(t => t.BuildType() != null)
-					.Where(t => t.BuildType() == name || t.BuildType().Contains("<" + name + ">")))
-				{
-					// check schema
-
-					if (cm.Parent != null && cm.Parent.Parent != null)
-					{
-						var parent = cm.Parent.Parent;
-
-						if (parent is Table)
-						{
-							var table = (Table)parent;
-
-							if (schema == table.Schema)
-								if (cm.Attributes.All(a => a.Name != text))
-									cm.Attributes.Add(obsoleteAttr);
-						}
-						else if (parent is Class)
-						{
-							var cls = (Class)parent;
-
-							bool parentClassIncludesSchemaName = cls.Name.Equals(schema + "Schema", StringComparison.InvariantCultureIgnoreCase);
-							bool classIsForDefaultSchema       = cls.Name == DataContextName;
-							bool isExtensionMethod             = cls.Parent is Namespace || cls.Name == "TableExtensions";
-
-							if (classIsForDefaultSchema || parentClassIncludesSchemaName || isExtensionMethod)
-								if (cm.Attributes.All(a => a.Name != text))
-									cm.Attributes.Add(obsoleteAttr);
-						}
-					}
-				}
-			}
-
-			afterGenerateLinqToDBModel();
-		};
-	}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/PluralizationService.ttinclude b/src/Database.T4/LinqToDB.Templates/PluralizationService.ttinclude
deleted file mode 100644
index 2bed1d6fe7c818c122b539e4f88a5acb1486186f..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/PluralizationService.ttinclude
+++ /dev/null
@@ -1,185 +0,0 @@
-<#@ assembly name="System.Data.Entity.Design"                          #>
-<#@ import namespace="System.Data.Entity.Design.PluralizationServices" #>
-<#
-	{
-		ToPlural   = Pluralization.ToPlural;
-		ToSingular = Pluralization.ToSingular;
-	}
-#>
-<#+
-static class Pluralization
-{
-	public static string CultureInfo = "en";
-
-	static PluralizationService _service;
-
-	public static Dictionary<string,string> Dictionary = new Dictionary<string,string>
-	{
-		{ "access",       "accesses"     }, { "afterlife",    "afterlives"   }, { "alga",         "algae"        },
-		{ "alumna",       "alumnae"      }, { "alumnus",      "alumni"       }, { "analysis",     "analyses"     },
-		{ "antenna",      "antennae"     }, { "appendix",     "appendices"   }, { "axis",         "axes"         },
-		{ "bacillus",     "bacilli"      }, { "basis",        "bases"        }, { "Bedouin",      "Bedouin"      },
-		{ "cactus",       "cacti"        }, { "calf",         "calves"       }, { "cherub",       "cherubim"     },
-		{ "child",        "children"     }, { "cod",          "cod"          }, { "cookie",       "cookies"      },
-		{ "criterion",    "criteria"     }, { "curriculum",   "curricula"    }, { "data",         "data"         },
-		{ "deer",         "deer"         }, { "diagnosis",    "diagnoses"    }, { "die",          "dice"         },
-		{ "dormouse",     "dormice"      }, { "elf",          "elves"        }, { "elk",          "elk"          },
-		{ "erratum",      "errata"       }, { "esophagus",    "esophagi"     }, { "fauna",        "faunae"       },
-		{ "fish",         "fish"         }, { "flora",        "florae"       }, { "focus",        "foci"         },
-		{ "foot",         "feet"         }, { "formula",      "formulae"     }, { "fundus",       "fundi"        },
-		{ "fungus",       "fungi"        }, { "genie",        "genii"        }, { "genus",        "genera"       },
-		{ "goose",        "geese"        }, { "grouse",       "grouse"       }, { "hake",         "hake"         },
-		{ "half",         "halves"       }, { "headquarters", "headquarters" }, { "hippo",        "hippos"       },
-		{ "hippopotamus", "hippopotami"  }, { "hoof",         "hooves"       }, { "housewife",    "housewives"   },
-		{ "hypothesis",   "hypotheses"   }, { "index",        "indices"      }, { "info",         "info"         },
-		{ "jackknife",    "jackknives"   },
-		{ "knife",        "knives"       }, { "labium",       "labia"        }, { "larva",        "larvae"       },
-		{ "leaf",         "leaves"       }, { "life",         "lives"        }, { "loaf",         "loaves"       },
-		{ "louse",        "lice"         }, { "magus",        "magi"         }, { "man",          "men"          },
-		{ "memorandum",   "memoranda"    }, { "midwife",      "midwives"     }, { "millennium",   "millennia"    },
-		{ "moose",        "moose"        }, { "mouse",        "mice"         }, { "nebula",       "nebulae"      },
-		{ "neurosis",     "neuroses"     }, { "nova",         "novas"        }, { "nucleus",      "nuclei"       },
-		{ "oesophagus",   "oesophagi"    }, { "offspring",    "offspring"    }, { "ovum",         "ova"          },
-		{ "ox",           "oxen"         }, { "papyrus",      "papyri"       }, { "passerby",     "passersby"    },
-		{ "penknife",     "penknives"    }, { "person",       "people"       }, { "phenomenon",   "phenomena"    },
-		{ "placenta",     "placentae"    }, { "pocketknife",  "pocketknives" }, { "process",      "processes"    },
-		{ "pupa",         "pupae"        }, { "radius",       "radii"        }, { "reindeer",     "reindeer"     },
-		{ "retina",       "retinae"      }, { "rhinoceros",   "rhinoceros"   }, { "roe",          "roe"          },
-		{ "salmon",       "salmon"       }, { "scarf",        "scarves"      }, { "self",         "selves"       },
-		{ "seraph",       "seraphim"     }, { "series",       "series"       }, { "sheaf",        "sheaves"      },
-		{ "sheep",        "sheep"        }, { "shelf",        "shelves"      }, { "species",      "species"      },
-		{ "spectrum",     "spectra"      }, { "status",       "status"       }, { "stimulus",     "stimuli"      },
-		{ "stratum",      "strata"       }, { "supernova",    "supernovas"   }, { "swine",        "swine"        },
-		{ "terminus",     "termini"      }, { "thesaurus",    "thesauri"     }, { "thesis",       "theses"       },
-		{ "thief",        "thieves"      }, { "trout",        "trout"        }, { "vulva",        "vulvae"       },
-		{ "wife",         "wives"        }, { "wildebeest",   "wildebeest"   }, { "wolf",         "wolves"       },
-		{ "woman",        "women"        }, { "yen",          "yen"          },
-	};
-
-	static string GetLastWord(string str)
-	{
-		if (string.IsNullOrWhiteSpace(str))
-			return string.Empty;
-
-		var i = str.Length - 1;
-		var isLower = char.IsLower(str[i]);
-
-		while (i > 0 && char.IsLetter(str[i - 1]) && char.IsLower(str[i - 1]) == isLower)
-			i--;
-
-		return str.Substring(isLower && i > 0 && char.IsLetter(str[i - 1]) ? i - 1 : i);
-	}
-
-	public static string ToPlural(string str)
-	{
-		if (_service == null)
-			_service = PluralizationService.CreateService(System.Globalization.CultureInfo.GetCultureInfo(CultureInfo));
-
-		var word = GetLastWord(str);
-
-		string newWord;
-
-		if (!Dictionary.TryGetValue(word.ToLower(), out newWord))
-			newWord = _service.IsPlural(word) ? word : _service.Pluralize(word);
-
-		if (string.Compare(word, newWord, true) != 0)
-		{
-			if (char.IsUpper(word[0]))
-				newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1).ToLower();
-
-			return word == str ? newWord : str.Substring(0, str.Length - word.Length) + newWord;
-		}
-
-		return str;
-	}
-
-	public static string ToSingular(string str)
-	{
-		if (_service == null)
-			_service = PluralizationService.CreateService(System.Globalization.CultureInfo.GetCultureInfo(CultureInfo));
-
-		var word = GetLastWord(str);
-
-		var newWord =
-			Dictionary
-				.Where(dic => string.Compare(dic.Value, word, true) == 0)
-				.Select(dic => dic.Key)
-				.FirstOrDefault()
-			??
-			(_service.IsSingular(word) ? word : _service.Singularize(word));
-
-		if (string.Compare(word, newWord, true) != 0)
-		{
-			if (char.IsUpper(word[0]))
-				newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1);
-
-			return word == str ? newWord : str.Substring(0, str.Length - word.Length) + newWord;
-		}
-
-		return str;
-	}
-
-	static string GetLastWordVersion1(string str)
-	{
-		if (string.IsNullOrWhiteSpace(str))
-			return string.Empty;
-
-		var i       = str.Length - 1;
-		var isLower = char.IsLower(str[i]);
-
-		while (i > 0 && char.IsLower(str[i-1]) == isLower)
-			i--;
-
-		return str.Substring(isLower && i > 0 ? i - 1 : i);
-	}
-
-	public static string ToPluralVersion1(string str)
-	{
-		if (_service == null)
-			_service = PluralizationService.CreateService(System.Globalization.CultureInfo.GetCultureInfo(CultureInfo));
-
-		var word = GetLastWordVersion1(str);
-
-		string newWord;
-
-		if (!Dictionary.TryGetValue(word.ToLower(), out newWord))
-			newWord = _service.IsPlural(word) ? word : _service.Pluralize(word);
-
-		if (string.Compare(word, newWord, true) != 0)
-		{
-			if (char.IsUpper(word[0]))
-				newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1);
-
-			return word == str ? newWord : str.Substring(0, str.Length - word.Length) + newWord;
-		}
-
-		return str;
-	}
-
-	public static string ToSingularVersion1(string str)
-	{
-		if (_service == null)
-			_service = PluralizationService.CreateService(System.Globalization.CultureInfo.GetCultureInfo(CultureInfo));
-
-		var word = GetLastWordVersion1(str);
-
-		var newWord =
-			Dictionary
-				.Where(dic => string.Compare(dic.Value, word, true) == 0)
-				.Select(dic => dic.Key)
-				.FirstOrDefault()
-			??
-			(_service.IsSingular(word) ? word : _service.Singularize(word));
-
-		if (string.Compare(word, newWord, true) != 0)
-		{
-			if (char.IsUpper(word[0]))
-				newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1);
-
-			return word == str ? newWord : str.Substring(0, str.Length - word.Length) + newWord;
-		}
-
-		return str;
-	}
-}
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/T4Model.ttinclude b/src/Database.T4/LinqToDB.Templates/T4Model.ttinclude
deleted file mode 100644
index 6a21ed784bbc0ead89c08fbbb4371a2d8676aa56..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/T4Model.ttinclude
+++ /dev/null
@@ -1,1812 +0,0 @@
-<#@ assembly name="System.Core"                   #>
-<#@ import namespace="System"                     #>
-<#@ import namespace="System.Collections.Generic" #>
-<#@ import namespace="System.Linq"                #>
-<#@ import namespace="System.Text"                #>
-<#+
-static Action<GeneratedTextTransformation,string> WriteComment    = (tt,s) => tt.WriteLine("//{0}", s);
-
-Action BeforeGenerateModel = () => {};
-
-bool GenerateProcedureErrors             = true;
-
-static bool EnableNullableReferenceTypes = false;
-static Func<string, bool> IsValueType    = IsValueTypeDefault;
-
-void GenerateModel()
-{
-	Model.SetTree();
-
-	if (GenerationEnvironment.Length > 0 && GenerationEnvironment.ToString().Trim().Length == 0)
-		GenerationEnvironment.Length = 0;
-
-	WriteComment(this, "---------------------------------------------------------------------------------------------------");
-	WriteComment(this, " <auto-generated>");
-	WriteComment(this, "    This code was generated by T4Model template for T4 (https://github.com/linq2db/linq2db).");
-	WriteComment(this, "    Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.");
-	WriteComment(this, " </auto-generated>");
-	WriteComment(this, "---------------------------------------------------------------------------------------------------");
-
-	WriteLine("");
-	WriteLine("#pragma warning disable 1591");
-	if (EnableNullableReferenceTypes)
-		WriteLine($"#nullable enable");
-	WriteLine("");
-
-	BeforeGenerateModel();
-
-	Model.Render(this);
-
-	WriteLine("");
-	WriteLine("#pragma warning restore 1591");
-}
-
-void Trim()
-{
-	var arr = new[] { '\r', '\n', ' ' };
-	while (GenerationEnvironment.Length > 0 && arr.Contains(GenerationEnvironment[GenerationEnvironment.Length - 1]))
-		GenerationEnvironment.Length--;
-
-	WriteLine("");
-}
-
-static Action<GeneratedTextTransformation,string> WriteUsing = (tt,s) => tt.WriteLine("using {0};", s);
-
-void RenderUsings(List<string> usings)
-{
-	var q =
-		from ns in usings.Distinct()
-		group ns by ns.Split('.')[0];
-
-	var groups =
-		(from ns in q where ns.Key == "System"                select ns).Concat
-		(from ns in q where ns.Key != "System" orderby ns.Key select ns);
-
-	foreach (var gr in groups)
-	{
-		foreach (var ns in from s in gr orderby s select s)
-			WriteUsing(this, ns);
-
-		WriteLine("");
-	}
-
-	Trim();
-}
-
-// Base data types.
-//
-public interface ITree
-{
-	ITree              Parent { get; set; }
-	IEnumerable<ITree> GetNodes();
-	void               SetTree();
-}
-
-ModelSource Model = new ModelSource();
-
-public partial class ModelSource : ITree
-{
-	public int CurrentNamespace = 0;
-
-	public List<string>    Usings     = new List<string>    { "System"        };
-	public List<Namespace> Namespaces = new List<Namespace> { new Namespace() };
-
-	public Namespace      Namespace { get { return Namespaces[CurrentNamespace];       } }
-	public List<TypeBase> Types     { get { return Namespaces[CurrentNamespace].Types; } }
-
-	public virtual void Render(GeneratedTextTransformation tt)
-	{
-		tt.RenderUsings(Usings);
-		tt.WriteLine("");
-
-		foreach (var nm in Namespaces)
-		{
-			nm.Render(tt);
-			tt.WriteLine("");
-		}
-
-		tt.Trim();
-	}
-
-	public ITree              Parent     { get; set; }
-	public IEnumerable<ITree> GetNodes() { return Namespaces; }
-
-	public void SetTree()
-	{
-		foreach (var ch in GetNodes())
-		{
-			ch.Parent = this;
-			ch.SetTree();
-		}
-	}
-}
-
-static Action<GeneratedTextTransformation,string> WriteBeginNamespace = (tt,s) => { tt.WriteLine("namespace {0}", s); tt.WriteLine("{"); };
-static Action<GeneratedTextTransformation>        WriteEndNamespace   =  tt    => tt.WriteLine("}");
-
-public partial class Namespace : ITree
-{
-	public string         Name;
-	public List<TypeBase> Types  = new List<TypeBase>();
-	public List<string>   Usings = new List<string>();
-
-	public virtual void Render(GeneratedTextTransformation tt)
-	{
-		if (!string.IsNullOrEmpty(Name))
-		{
-			WriteBeginNamespace(tt, Name);
-			tt.PushIndent("\t");
-		}
-
-		tt.RenderUsings(Usings);
-
-		foreach (var t in Types)
-		{
-			t.Render(tt);
-			tt.WriteLine("");
-		}
-
-		tt.Trim();
-
-		if (!string.IsNullOrEmpty(Name))
-		{
-			tt.PopIndent();
-			WriteEndNamespace(tt);
-		}
-	}
-
-	public ITree              Parent     { get; set; }
-	public IEnumerable<ITree> GetNodes() { return Types; }
-
-	public void SetTree()
-	{
-		foreach (var ch in GetNodes())
-		{
-			ch.Parent = this;
-			ch.SetTree();
-		}
-	}
-}
-
-public interface IClassMember : ITree
-{
-}
-
-public enum AccessModifier
-{
-	Public,
-	Protected,
-	Internal,
-	Private,
-	Partial,
-	None
-}
-
-public abstract partial class TypeBase : IClassMember
-{
-	public AccessModifier  AccessModifier = AccessModifier.Public;
-	public string          Name;
-	public bool            IsPartial  = true;
-	public List<string>    Comment    = new List<string>();
-	public List<Attribute> Attributes = new List<Attribute>();
-	public string          Conditional;
-	public string          ClassKeyword = "class";
-
-	public abstract void Render(GeneratedTextTransformation tt);
-
-	protected virtual void BeginConditional(GeneratedTextTransformation tt)
-	{
-		if (Conditional != null)
-		{
-			tt.RemoveSpace();
-			tt.WriteLine("#if " + Conditional);
-			tt.WriteLine("");
-		}
-	}
-
-	protected virtual void EndConditional(GeneratedTextTransformation tt)
-	{
-		if (Conditional != null)
-		{
-			tt.RemoveSpace();
-			tt.WriteLine("");
-			tt.RemoveSpace();
-			tt.WriteLine("#endif");
-		}
-	}
-
-	public          ITree              Parent { get; set; }
-	public abstract IEnumerable<ITree> GetNodes();
-	public abstract void               SetTree ();
-}
-
-static Action<GeneratedTextTransformation,Class> WriteBeginClass = (tt,cl) =>
-{
-	tt.Write(cl.AccessModifier.ToString().ToLower() + " ");
-	if (cl.IsStatic)  tt.Write("static ");
-	if (cl.IsPartial) tt.Write("partial ", cl.Name);
-	tt.Write("{0} {1}{2}", cl.ClassKeyword, cl.Name, cl.GenericArguments.Count > 0 ? $"<{string.Join(", ", cl.GenericArguments)}>" : string.Empty);
-
-	if (!string.IsNullOrEmpty(cl.BaseClass) || cl.Interfaces.Count > 0)
-	{
-		var arr = new[] { cl.BaseClass }.Concat(cl.Interfaces)
-			.Where(n => n != null)
-			.ToArray();
-
-		tt.Write(" : ");
-		tt.Write(string.Join(", ", arr));
-	}
-
-	tt.WriteLine("");
-	tt.WriteLine("{");
-};
-
-static Action<GeneratedTextTransformation> WriteEndClass = tt => tt.WriteLine("}");
-
-public partial class Class : TypeBase
-{
-	public string             BaseClass;
-	public List<string>       GenericArguments   = new List<string>();
-	public bool               IsStatic           = false;
-	public List<string>       Interfaces         = new List<string>();
-	public List<IClassMember> Members            = new List<IClassMember>();
-
-	public Class()
-	{
-	}
-
-	public Class(string name, params IClassMember[] members)
-	{
-		Name = name;
-		Members.AddRange(members);
-	}
-
-	public override void Render(GeneratedTextTransformation tt)
-	{
-		BeginConditional(tt);
-
-		foreach (var c in Comment)
-			tt.WriteLine("//" + c);
-
-		if (Attributes.Count > 0)
-		{
-			var aa = Attributes.Where(a => !a.IsSeparated).ToList();
-
-			if (aa.Count > 0)
-			{
-				tt.Write("[");
-
-				for (var i = 0; i < aa.Count; i++)
-				{
-					if (i > 0) SkipSpacesAndInsert(tt, ", ");
-					aa[i].Render(tt);
-				}
-
-				tt.WriteLine("]");
-			}
-
-			aa = Attributes.Where(a => a.IsSeparated).ToList();
-
-			foreach (var a in aa)
-			{
-				tt.Write("[");
-				a.Render(tt);
-				tt.WriteLine("]");
-			}
-		}
-
-		WriteBeginClass(tt, this);
-		tt.PushIndent("\t");
-
-		foreach (var cm in Members)
-		{
-			if (cm is MemberBase)
-			{
-				var m = (MemberBase)cm;
-
-				if (!(m is MemberGroup))
-					m.BeginConditional(tt, false);
-
-				foreach (var c in m.Comment)
-					WriteComment(tt, c);
-
-				if (m.Attributes.Count > 0)
-				{
-					var q =
-						from a in m.Attributes
-						group a by a.Conditional ?? "";
-
-					foreach (var g in q)
-					{
-						if (g.Key.Length > 0)
-						{
-							tt.RemoveSpace();
-							tt.WriteLine("#if " + g.Key);
-						}
-
-						var attrs = g.ToList();
-
-						tt.Write("[");
-
-						for (var i = 0; i < attrs.Count; i++)
-						{
-							if (i > 0) SkipSpacesAndInsert(tt, ", ");
-							attrs[i].Render(tt);
-						}
-
-						tt.WriteLine("]");
-
-						if (g.Key.Length > 0)
-						{
-							tt.RemoveSpace();
-							tt.WriteLine("#endif");
-						}
-					}
-				}
-
-				m.Render(tt, false);
-				if (m.InsertBlankLineAfter)
-					tt.WriteLine("");
-
-				if (!(m is MemberGroup))
-					m.EndConditional(tt, false);
-			}
-			else if (cm is TypeBase)
-			{
-				var t = (TypeBase)cm;
-
-				t.Render(tt);
-				tt.WriteLine("");
-			}
-		}
-
-		tt.Trim();
-
-		tt.PopIndent();
-		WriteEndClass(tt);
-
-		EndConditional(tt);
-	}
-
-	public override IEnumerable<ITree> GetNodes()
-	{
-		return Members;
-	}
-
-	public override void SetTree()
-	{
-		foreach (var ch in GetNodes())
-		{
-			ch.Parent = this;
-			ch.SetTree();
-		}
-	}
-}
-
-public abstract partial class MemberBase : IClassMember
-{
-	public string          ID;
-	public AccessModifier  AccessModifier = AccessModifier.Public;
-	public string          Name;
-	public Func<string>    TypeBuilder;
-	public List<string>    Comment = new List<string>();
-	public string          EndLineComment;
-	public List<Attribute> Attributes = new List<Attribute>();
-	public bool            InsertBlankLineAfter = true;
-	public string          Conditional;
-
-	public int AccessModifierLen;
-	public int ModifierLen;
-	public int TypeLen;
-	public int NameLen;
-	public int ParamLen;
-	public int BodyLen;
-
-	public string Type
-	{
-		get { return TypeBuilder?.Invoke(); }
-		set { TypeBuilder = () => value;    }
-	}
-
-	public string BuildType() { return TypeBuilder?.Invoke(); }
-
-	public virtual  int  CalcModifierLen() { return 0; }
-	public abstract int  CalcBodyLen    ();
-	public virtual  int  CalcParamLen   () { return 0; }
-	public abstract void Render         (GeneratedTextTransformation tt, bool isCompact);
-
-	public virtual void BeginConditional(GeneratedTextTransformation tt, bool isCompact)
-	{
-		if (Conditional != null)
-		{
-			tt.RemoveSpace();
-			tt.WriteLine("#if " + Conditional);
-			if (!isCompact)
-				tt.WriteLine("");
-		}
-	}
-
-	public virtual void EndConditional(GeneratedTextTransformation tt, bool isCompact)
-	{
-		if (Conditional != null)
-		{
-			tt.RemoveSpace();
-			tt.WriteLine("#endif");
-			if (!isCompact)
-				tt.WriteLine("");
-		}
-	}
-
-	public         ITree              Parent     { get; set; }
-	public virtual IEnumerable<ITree> GetNodes() { return Enumerable.Empty<ITree>(); }
-	public virtual void               SetTree () {}
-}
-
-static Action<GeneratedTextTransformation,string> BeginRegion = (tt,s) => { tt.WriteLine("#region {0}", s); };
-static Action<GeneratedTextTransformation>        EndRegion   = (tt)   => { tt.WriteLine("#endregion");     };
-
-public partial class MemberGroup : MemberBase
-{
-	public string             Region;
-	public bool               IsCompact;
-	public bool               IsPropertyGroup;
-	public List<IClassMember> Members = new List<IClassMember>();
-	public List<string>       Errors  = new List<string>();
-
-	public override int  CalcBodyLen() { return 0; }
-
-	public override void Render(GeneratedTextTransformation tt, bool isCompact)
-	{
-		if (!string.IsNullOrEmpty(Region))
-		{
-			BeginRegion(tt, Region);
-			tt.WriteLine("");
-		}
-
-		BeginConditional(tt, isCompact);
-
-		if (Errors.Count > 0 && tt.GenerateProcedureErrors)
-		{
-			tt.RemoveSpace();
-			WriteComment(tt, " Use 'GenerateProcedureErrors=false' to disable errors.");
-			foreach (var error in Errors)
-			{
-				tt.Error(error);
-
-				foreach (var e in error.Split('\n'))
-				{
-					tt.RemoveSpace();
-					tt.WriteLine("#error " + e.Trim('\r'));
-				}
-			}
-
-			tt.WriteLine("");
-		}
-
-		if (IsCompact)
-		{
-			var allMembers = GetTreeNodes(this).OfType<MemberBase>().Where(m => !(m is MemberGroup)).ToList();
-
-			if (allMembers.Count > 0)
-			{
-				int max = allMembers.Max(m => m.AccessModifier == AccessModifier.None ? 0 : m.AccessModifier.ToString().Length);
-				foreach (var m in allMembers)
-					m.AccessModifierLen = max;
-
-				max = allMembers.Max(m => m.CalcModifierLen());
-				foreach (var m in allMembers)
-					m.ModifierLen = max;
-
-				max = allMembers.Max(m => (m.BuildType() ?? "").Length);
-				foreach (var m in allMembers)
-					m.TypeLen = max;
-
-				var notHasGetter = allMembers.OfType<Property>().Any(m => m.IsAuto && !m.HasGetter);
-				var notHasSetter = allMembers.OfType<Property>().Any(m => m.IsAuto && !m.HasSetter);
-
-				foreach (var p in allMembers.OfType<Property>())
-				{
-					if (notHasGetter) p.GetterLen = 13;
-					if (notHasSetter) p.SetterLen = 13;
-				}
-
-				max = allMembers.Max(m => m.Name.Length);
-				foreach (var m in allMembers)
-					m.NameLen = max;
-
-				max = allMembers.Max(m => m.CalcParamLen());
-				foreach (var m in allMembers)
-					m.ParamLen = max;
-
-				max = allMembers.Max(m => m.CalcBodyLen());
-				foreach (var m in allMembers)
-					m.BodyLen = max;
-
-				var members =
-				(
-					from m in allMembers
-					select new
-					{
-						m,
-						attrs =
-						(
-							from a in m.Attributes
-							group a by a.Name into gr
-							select gr.Select((a,i) => new { a, name = a.Name + "." + i }).ToList() into s
-							from a in s
-							select a
-						).ToList()
-					}
-				).ToList();
-
-				var attrWeight =
-				(
-					from m in members
-					from a in m.attrs
-					group a by a.name into gr
-					select new { gr.Key, Count = gr.Count() }
-				).ToDictionary(a => a.Key, a => a.Count);
-
-				var q =
-					from m in members
-					where m.attrs.Count > 0
-					select new { m, w = m.attrs.Sum(aa => attrWeight[aa.name]) } into m
-					orderby m.w descending
-					select m.m;
-
-				var attrs = new List<string>();
-
-				foreach (var m in q)
-				{
-					var list = m.attrs.Select(a => a.name).ToList();
-
-					if (attrs.Count == 0)
-						attrs.AddRange(list);
-					else
-					{
-						for (var i = 0; i < list.Count; i++)
-						{
-							var nm = list[i];
-
-							if (!attrs.Contains(nm))
-							{
-								for (var j = i + 1; j < list.Count; j++)
-								{
-									var idx = attrs.IndexOf(list[j]);
-
-									if (idx >= 0)
-									{
-										attrs.Insert(idx, nm);
-										break;
-									}
-								}
-							}
-
-							if (!attrs.Contains(nm))
-								attrs.Add(nm);
-						}
-					}
-				}
-
-				var mms = members.Select(m =>
-				{
-					var arr = new Attribute[attrs.Count];
-
-					foreach (var a in m.attrs)
-						arr[attrs.IndexOf(a.name)] = a.a;
-
-					return new { m.m, attrs = arr.ToList() };
-				}).ToList();
-
-				var idxs = Enumerable.Range(0, attrs.Count).Select(_ => new List<int>()).ToList();
-
-				for (var i = 0; i < mms.Count; i++)
-					for (var j = 0; j < mms[i].attrs.Count; j++)
-						if (mms[i].attrs[j] != null)
-							idxs[j].Add(i);
-
-				var toRemove = new List<int>();
-
-				for (int i = 1; i < idxs.Count; i++)
-				{
-					for (int j = 0; j < i; j++)
-					{
-						if (idxs[j] == null)
-							continue;
-
-						if (idxs[i].Intersect(idxs[j]).Count() == 0)
-						{
-							foreach (var m in mms)
-							{
-								if (m.attrs[i] != null)
-								{
-									m.attrs[j] = m.attrs[i];
-									m.attrs[i] = null;
-								}
-							}
-
-							idxs[j].AddRange(idxs[i]);
-							idxs[i] = null;
-							toRemove.Add(i);
-							break;
-						}
-					}
-
-				}
-
-				foreach (var n in toRemove.OrderByDescending(i => i))
-					foreach (var m in mms)
-						m.attrs.RemoveAt(n);
-
-				var lens = new int[attrs.Count - toRemove.Count];
-
-				foreach (var m in mms)
-				{
-					for (var i = 0; i < m.attrs.Count; i++)
-					{
-						var a = m.attrs[i];
-
-						if (a != null)
-						{
-							var len = a.Name.Length;
-
-							if (a.Parameters.Count >= 0)
-								len += a.Parameters.Sum(p => 2 + p.Length);
-
-							lens[i] = Math.Max(lens[i], len);
-						}
-					}
-				}
-
-				foreach (var m in allMembers)
-				{
-					if (!(m is MemberGroup))
-						m.BeginConditional(tt, IsCompact);
-
-					foreach (var c in m.Comment)
-						WriteComment(tt, c);
-
-					if (attrs.Count > 0)
-					{
-						var ma = mms.First(mr => mr.m == m);
-
-						if (m.Attributes.Count > 0)
-						{
-							tt.Write("[");
-
-							for (var i = 0; i < ma.attrs.Count; i++)
-							{
-								var a = ma.attrs[i];
-
-								if (a == null)
-								{
-									tt.WriteSpaces(lens[i]);
-									if (i + 1 < ma.attrs.Count)
-										tt.Write("  ");
-								}
-								else
-								{
-									var len = tt.GenerationEnvironment.Length;
-									a.Render(tt);
-									len = (tt.GenerationEnvironment.Length - len);
-
-									var commaAdded = false;
-
-									for (var j = i + 1; j < ma.attrs.Count; j++)
-									{
-										if (ma.attrs[j] != null)
-										{
-											SkipSpacesAndInsert(tt, ", ");
-											commaAdded = true;
-											break;
-										}
-									}
-
-									if (i + 1 < ma.attrs.Count && !commaAdded)
-										tt.Write("  ");
-
-									tt.WriteSpaces(lens[i] - len);
-								}
-							}
-
-							tt.Write("] ");
-						}
-						else
-						{
-							tt.WriteSpaces(lens.Sum() + ma.attrs.Count * 2 + 1);
-						}
-					}
-
-					m.Render(tt, true);
-
-					if (!IsCompact)
-						tt.WriteLine("");
-
-					if (!(m is MemberGroup))
-						m.EndConditional(tt, IsCompact);
-				}
-			}
-		}
-		else
-		{
-			foreach (var cm in Members)
-			{
-				if (cm is MemberBase)
-				{
-					var m = (MemberBase)cm;
-
-					if (!(m is MemberGroup))
-						m.BeginConditional(tt, IsCompact);
-
-					foreach (var c in m.Comment)
-						WriteComment(tt, c);
-
-					if (m.Attributes.Count > 0)
-					{
-						var q =
-							from a in m.Attributes
-							group a by a.Conditional ?? "";
-
-						foreach (var g in q)
-						{
-							if (g.Key.Length > 0)
-							{
-								tt.RemoveSpace();
-								tt.WriteLine("#if " + g.Key);
-							}
-
-							var attrs = g.ToList();
-
-							var aa = attrs.Where(a => !a.IsSeparated).ToList();
-
-							if (aa.Count > 0)
-							{
-								tt.Write("[");
-
-								for (var i = 0; i < aa.Count; i++)
-								{
-									if (i > 0) tt.Write(", ");
-									aa[i].Render(tt);
-								}
-
-								tt.WriteLine("]");
-							}
-
-							aa = attrs.Where(a => a.IsSeparated).ToList();
-
-							foreach (var a in aa)
-							{
-								tt.Write("[");
-								a.Render(tt);
-								tt.WriteLine("]");
-							}
-
-							if (g.Key.Length > 0)
-							{
-								tt.RemoveSpace();
-								tt.WriteLine("#endif");
-							}
-						}
-					}
-
-					m.Render(tt, false);
-
-					if (m.InsertBlankLineAfter)
-						tt.WriteLine("");
-
-					if (!(m is MemberGroup))
-						m.EndConditional(tt, IsCompact);
-				}
-				else if (cm is TypeBase)
-				{
-					var t = (TypeBase)cm;
-
-					t.Render(tt);
-					tt.WriteLine("");
-				}
-			}
-		}
-
-		tt.Trim();
-
-		EndConditional(tt, isCompact);
-
-		if (!string.IsNullOrEmpty(Region))
-		{
-			tt.WriteLine("");
-			EndRegion(tt);
-		}
-	}
-
-	public override IEnumerable<ITree> GetNodes() { return Members; }
-
-	public override void SetTree()
-	{
-		foreach (var ch in GetNodes())
-		{
-			ch.Parent = this;
-			ch.SetTree();
-		}
-	}
-}
-
-static Action<GeneratedTextTransformation,Field> WriteField = (tt,f) =>
-{
-	var am = f.AccessModifier.ToString().ToLower();
-	var mdf =
-		(f.IsStatic   ? " static"   : "") +
-		(f.IsReadonly ? " readonly" : "") ;
-
-	tt.Write("{0}{1}{2}{3} {4}{5} {6}",
-		am,            LenDiff(f.AccessModifierLen, am),
-		mdf,           LenDiff(f.ModifierLen,       mdf),
-		f.BuildType(), LenDiff(f.TypeLen,           f.BuildType()),
-		f.Name);
-
-	if (f.InitValue != null)
-	{
-		tt.Write(" = {0}", f.InitValue);
-	}
-
-	tt.Write(";");
-
-	if (!string.IsNullOrEmpty(f.EndLineComment))
-	{
-		tt.WriteSpaces(f.NameLen - f.Name.Length + f.BodyLen + f.ParamLen - 1);
-		tt.Write(" ");
-		WriteComment(tt, " " + f.EndLineComment);
-	}
-	else
-		tt.WriteLine("");
-};
-
-public partial class Field : MemberBase
-{
-	public bool   IsStatic;
-	public bool   IsReadonly;
-	public string InitValue;
-
-	public Field()
-	{
-	}
-
-	public Field(ModelType type, string name)
-	{
-		TypeBuilder = () => type.ToTypeName();
-		Name = name;
-	}
-
-	public Field(Func<string> typeBuilder, string name)
-	{
-		TypeBuilder = typeBuilder;
-		Name = name;
-	}
-
-	public override int CalcModifierLen()
-	{
-		return
-			(IsStatic   ? " static".  Length : 0) +
-			(IsReadonly ? " readonly".Length : 0) ;
-	}
-
-	public override int  CalcBodyLen() { return InitValue == null ? 1 : 4 + InitValue.Length; }
-
-	public override void Render(GeneratedTextTransformation tt, bool isCompact)
-	{
-		WriteField(tt, this);
-	}
-}
-
-static Action<GeneratedTextTransformation,Event> WriteEvent = (tt,m) =>
-{
-	var am  = m.AccessModifier.ToString().ToLower();
-	var mdf =
-		(m.IsStatic  ? " static"  : "") +
-		(m.IsVirtual ? " virtual" : "") +
-		" event";
-
-	tt.Write("{0}{1}{2}{3} {4}{5} {6};",
-		am,            LenDiff(m.AccessModifierLen, am),
-		mdf,           LenDiff(m.ModifierLen,       mdf),
-		m.BuildType(), LenDiff(m.TypeLen,           m.BuildType()),
-		m.Name);
-
-	if (!string.IsNullOrEmpty(m.EndLineComment))
-	{
-		tt.WriteSpaces(m.NameLen - m.Name.Length + m.BodyLen + m.ParamLen - 1);
-		tt.Write(" ");
-		WriteComment(tt, " " + m.EndLineComment);
-	}
-	else
-		tt.WriteLine("");
-};
-
-public partial class Event : MemberBase
-{
-	public bool IsStatic;
-	public bool IsVirtual;
-
-	public Event()
-	{
-	}
-
-	public Event(Type eventType, string name, bool nullable)
-	{
-		TypeBuilder = () => new ModelType(eventType, nullable).ToTypeName();
-		Name = name;
-	}
-
-	public Event(string eventType, string name, bool nullable)
-	{
-		TypeBuilder = () => new ModelType(eventType, true, nullable).ToTypeName();
-		Name = name;
-	}
-
-	public Event(Func<string> typeBuilder, string name)
-	{
-		TypeBuilder = typeBuilder;
-		Name = name;
-	}
-
-	public override int CalcModifierLen()
-	{
-		return
-			(IsStatic  ? " static". Length : 0) +
-			(IsVirtual ? " virtual".Length : 0) +
-			" event".Length;
-	}
-
-	public override int CalcBodyLen() { return 1; }
-
-	public override void Render(GeneratedTextTransformation tt, bool isCompact)
-	{
-		WriteEvent(tt, this);
-	}
-}
-
-static Action<GeneratedTextTransformation,Property,bool> WriteProperty = (tt,p,compact) =>
-{
-	var am  = p.AccessModifier == AccessModifier.None ? "" : p.AccessModifier.ToString().ToLower() + " ";
-	var mdf = p.IsAbstract ? "abstract " : p.IsVirtual ? "virtual " : p.IsOverride ? "override " : p.IsStatic ? "static " : "";
-
-	tt.Write("{0}{1}{2}{3}{4}{5} {6}",
-		am,            LenDiff(p.AccessModifierLen, am),
-		mdf,           LenDiff(p.ModifierLen,       mdf),
-		p.BuildType(), LenDiff(p.TypeLen,           p.BuildType()),
-		p.Name);
-
-	Action writeComment = () =>
-	{
-		if (!string.IsNullOrEmpty(p.EndLineComment))
-		{
-			tt.Write(" ");
-			WriteComment(tt, " " + p.EndLineComment);
-		}
-		else
-			tt.WriteLine("");
-	};
-
-	if (p.IsAuto)
-	{
-		tt.Write(LenDiff(p.NameLen + p.ParamLen, p.Name));
-
-		var len = tt.GenerationEnvironment.Length;
-
-		tt.Write(" { ");
-
-		if (!p.HasGetter)
-			tt.Write("private ");
-		else if (p.GetterLen == 13)
-			tt.Write("        ");
-		tt.Write("get; ");
-
-		if (!p.HasSetter)
-			tt.Write("private ");
-		else if (p.SetterLen == 13)
-			tt.Write("        ");
-		tt.Write("set; ");
-
-		tt.Write("}");
-
-		if (p.EnforceNotNullable)
-			tt.Write(" = null!;");
-
-		if (!string.IsNullOrEmpty(p.EndLineComment))
-			tt.WriteSpaces(p.BodyLen - (tt.GenerationEnvironment.Length - len));
-		writeComment();
-	}
-	else
-	{
-		if (compact)
-		{
-			tt.Write(LenDiff(p.NameLen + p.ParamLen, p.Name));
-
-			var len = tt.GenerationEnvironment.Length;
-
-			tt.Write(" { ");
-
-			if (p.HasGetter)
-			{
-				tt.Write("get { ");
-				foreach (var t in p.BuildGetBody())
-					tt.Write("{0} ", t);
-				tt.Write("} ");
-			}
-
-			if (p.HasSetter)
-			{
-				tt.Write("set { ");
-				foreach (var t in p.BuildSetBody())
-					tt.Write("{0} ", t);
-				tt.Write("} ");
-			}
-
-			tt.Write("}");
-
-			if (!string.IsNullOrEmpty(p.EndLineComment))
-				tt.WriteSpaces(p.BodyLen - (tt.GenerationEnvironment.Length - len));
-			writeComment();
-		}
-		else
-		{
-			writeComment();
-
-			tt.WriteLine("{");
-			tt.PushIndent("\t");
-
-			if (p.HasGetter)
-			{
-				var getBody = p.BuildGetBody().ToArray();
-				if (getBody.Length == 1)
-				{
-					tt.WriteLine("get {{ {0} }}", getBody[0]);
-				}
-				else
-				{
-					tt.WriteLine("get");
-					tt.WriteLine("{");
-					tt.PushIndent("\t");
-
-					foreach (var t in getBody)
-						tt.WriteLine(t);
-
-					tt.PopIndent();
-					tt.WriteLine("}");
-				}
-			}
-
-			if (p.HasSetter)
-			{
-				var setBody = p.BuildSetBody().ToArray();
-				if (setBody.Length == 1)
-				{
-					tt.WriteLine("set {{ {0} }}", setBody[0]);
-				}
-				else
-				{
-					tt.WriteLine("set");
-					tt.WriteLine("{");
-					tt.PushIndent("\t");
-
-					foreach (var t in setBody)
-						tt.WriteLine(t);
-
-					tt.PopIndent();
-					tt.WriteLine("}");
-				}
-			}
-
-			tt.PopIndent();
-			tt.WriteLine("}");
-		}
-	}
-};
-
-public partial class Property : MemberBase
-{
-	public bool         IsAuto    = true;
-	public string       InitValue;
-	public bool         IsVirtual;
-	public bool         IsOverride;
-	public bool         IsAbstract;
-	public bool         IsStatic;
-	public bool         HasGetter = true;
-	public bool         HasSetter = true;
-	public List<Func<IEnumerable<string>>> GetBodyBuilders = new List<Func<IEnumerable<string>>>();
-	public List<Func<IEnumerable<string>>> SetBodyBuilders = new List<Func<IEnumerable<string>>>();
-
-	public int GetterLen = 5;
-	public int SetterLen = 5;
-
-	public Property()
-	{
-	}
-
-	public Property(ModelType type, string name, Func<IEnumerable<string>> getBodyBuilder = null, Func<IEnumerable<string>> setBodyBuilder = null)
-	{
-		TypeBuilder = () => type.ToTypeName();
-		Name        = name;
-
-		InitBody(getBodyBuilder, setBodyBuilder);
-	}
-
-	public Property(bool enforceNotNullable, Func<string> typeBuilder, string name, Func<IEnumerable<string>> getBodyBuilder = null, Func<IEnumerable<string>> setBodyBuilder = null)
-		: this(typeBuilder, name, getBodyBuilder, setBodyBuilder)
-	{
-		EnforceNotNullable = enforceNotNullable;
-	}
-
-	public Property(Func<string> typeBuilder, string name, Func<IEnumerable<string>> getBodyBuilder = null, Func<IEnumerable<string>> setBodyBuilder = null)
-	{
-		TypeBuilder = typeBuilder;
-		Name = name;
-
-		InitBody(getBodyBuilder, setBodyBuilder);
-	}
-
-	public override int CalcModifierLen()
-	{
-		return IsVirtual ? " virtual".Length : 0;
-	}
-
-	public override int CalcBodyLen()
-	{
-		if (IsAuto)
-			return 4 + GetterLen + SetterLen; // ' { get; set; }'
-
-		var len = " {".Length;
-
-		if (HasGetter)
-		{
-			len += " get {".Length;
-			foreach (var t in BuildGetBody())
-				len += 1 + t.Length;
-			len += " }".Length;
-		}
-
-		if (HasSetter)
-		{
-			len += " set {".Length;
-			foreach (var t in BuildSetBody())
-				len += 1 + t.Length;
-			len += " }".Length;
-		}
-
-		len += " }".Length;
-
-		return len;
-	}
-
-	public override void Render(GeneratedTextTransformation tt, bool isCompact)
-	{
-		if (!IsAuto && HasGetter)
-		{
-			var getBody = BuildGetBody().ToArray();
-			if (getBody.Length == 1)
-			{
-				var t = getBody[0];
-
-				if (!t.StartsWith("return"))
-				{
-					t = "return " + t;
-
-					if (!t.EndsWith(";"))
-						t += ";";
-
-					GetBodyBuilders.Clear();
-					GetBodyBuilders.Add(() => new [] { t });
-				}
-			}
-		}
-
-		WriteProperty(tt, this, isCompact);
-	}
-
-	public Property InitBody(Func<IEnumerable<string>> getBodyBuilder = null, Func<IEnumerable<string>> setBodyBuilder = null)
-	{
-		IsAuto = getBodyBuilder == null && setBodyBuilder == null;
-
-		if (getBodyBuilder != null) GetBodyBuilders.Add(getBodyBuilder);
-		if (setBodyBuilder != null) SetBodyBuilders.Add(setBodyBuilder);
-
-		if (!IsAuto)
-		{
-			HasGetter = getBodyBuilder != null;
-			HasSetter = setBodyBuilder != null;
-		}
-
-		return this;
-	}
-
-	public Property InitGetter(Func<IEnumerable<string>> getBodyBuilder)
-	{
-		return InitBody(getBodyBuilder, null);
-	}
-
-	public IEnumerable<string> BuildGetBody()
-	{
-		return GetBodyBuilders.SelectMany(builder => builder?.Invoke() ?? Array.Empty<string>());
-	}
-
-	public IEnumerable<string> BuildSetBody()
-	{
-		return SetBodyBuilders.SelectMany(builder => builder?.Invoke() ?? Array.Empty<string>());
-	}
-
-	protected internal virtual bool EnforceNotNullable { get; }
-}
-
-static Action<GeneratedTextTransformation,Method,bool> WriteMethod = (tt,m,compact) =>
-{
-	var am1  = m.AccessModifier.ToString().ToLower();
-	var len1 = m.AccessModifierLen;
-	var am2  = "";
-	var len2 = 0;
-	var mdf  = m.IsAbstract ? " abstract" : m.IsVirtual ? " virtual" : m.IsOverride ? " override" : m.IsStatic ? " static" : "";
-	var mlen = m.ModifierLen;
-
-	if (am1 == "partial" && mdf.Length > 0)
-	{
-		am2 = " " + am1; len2 = len1 + 1;
-		am1 = "";        len1 = 0;
-		mdf = mdf.Trim();
-		mlen--;
-	}
-
-	tt.Write("{0}{1}{2}{3}{4}{5}{6}{7}{8} {9}{10}",
-		am1,           LenDiff(len1, am1),
-		mdf,           LenDiff(mlen, mdf),
-		am2,           LenDiff(len2, am2),
-		m.BuildType() == null ? "" : " ",
-		m.BuildType(), LenDiff(m.TypeLen,     m.BuildType() ?? ""),
-		m.Name,
-		m.GenericArguments.Count > 0 ? $"<{string.Join(", ", m.GenericArguments)}>" : string.Empty);
-
-	Action writeComment = () =>
-	{
-		if (!string.IsNullOrEmpty(m.EndLineComment))
-		{
-			tt.Write(" ");
-			WriteComment(tt, " " + m.EndLineComment);
-		}
-		else
-			tt.WriteLine("");
-	};
-
-	Action writeParams = () =>
-	{
-		tt.Write("(");
-
-		for (int i = 0; i < m.ParameterBuilders.Count; i++)
-		{
-			if (i > 0)
-				tt.Write(", ");
-			tt.Write(m.ParameterBuilders[i]());
-		}
-
-		tt.Write(")");
-	};
-
-	if (compact)
-	{
-		tt.Write(LenDiff(m.NameLen, m.Name));
-
-		var len = tt.GenerationEnvironment.Length;
-
-		writeParams();
-
-		foreach (var s in m.AfterSignature)
-		{
-			tt.Write(" ");
-			tt.Write(s);
-		}
-
-		len = tt.GenerationEnvironment.Length - len;
-
-		if (m.IsAbstract || m.AccessModifier == AccessModifier.Partial)
-		{
-			tt.Write(";");
-			len = 0;
-		}
-		else
-		{
-			tt.WriteSpaces(m.ParamLen - len);
-
-			len = tt.GenerationEnvironment.Length;
-
-			tt.Write(" {");
-
-			foreach (var t in m.BuildBody())
-				tt.Write(" {0}", t);
-
-			tt.Write(" }");
-		}
-
-		if (!string.IsNullOrEmpty(m.EndLineComment))
-			tt.WriteSpaces(m.BodyLen - (tt.GenerationEnvironment.Length - len));
-		writeComment();
-	}
-	else
-	{
-		writeParams ();
-		writeComment();
-
-		tt.PushIndent("\t");
-		foreach (var s in m.AfterSignature)
-			tt.WriteLine(s);
-		tt.PopIndent();
-
-		tt.WriteLine("{");
-		tt.PushIndent("\t");
-
-		foreach (var t in m.BuildBody())
-		{
-			if (t.Length > 1 && t[0] == '#')
-			{
-				tt.RemoveSpace();
-			}
-
-			tt.WriteLine(t);
-		}
-
-		tt.PopIndent();
-		tt.WriteLine("}");
-	}
-};
-
-public partial class Method : MemberBase
-{
-	public bool         IsAbstract;
-	public bool         IsVirtual;
-	public bool         IsOverride;
-	public bool         IsStatic;
-	public List<string> GenericArguments        = new List<string>();
-	public List<string> AfterSignature          = new List<string>();
-	public List<Func<string>> ParameterBuilders = new List<Func<string>>();
-	public List<Func<IEnumerable<string>>> BodyBuilders = new List<Func<IEnumerable<string>>>();
-
-	public Method()
-	{
-	}
-
-	public Method(Func<string> typeBuilder, string name, IEnumerable<Func<string>> parameterBuilders = null, params Func<IEnumerable<string>>[] bodyBuilders)
-	{
-		TypeBuilder = typeBuilder;
-		Name = name;
-
-		if (parameterBuilders  != null) ParameterBuilders.AddRange(parameterBuilders);
-		if (bodyBuilders       != null) BodyBuilders.AddRange(bodyBuilders);
-	}
-
-	public static Method Create(string type, string name, IEnumerable<string> parameters = null, IEnumerable<string> body = null)
-	{
-		return new Method(
-			() => type,
-			name,
-			parameters?.Select<string,Func<string>>((string p) => () => p),
-			body?.Select<string,Func<IEnumerable<string>>>(p => () => new[] { p }).ToArray());
-	}
-
-	public IEnumerable<string> BuildBody()
-	{
-		return BodyBuilders.SelectMany(builder => builder?.Invoke() ?? Array.Empty<string>());
-	}
-
-	public override int CalcModifierLen()
-	{
-		return
-			IsAbstract ? " abstract".Length :
-			IsVirtual  ? " virtual".Length  :
-			IsStatic   ? " static".Length   : 0;
-	}
-
-	public override int CalcBodyLen()
-	{
-		if (IsAbstract || AccessModifier == AccessModifier.Partial)
-			return 1;
-
-		var len = " {".Length;
-
-		foreach (var t in BuildBody())
-			len += 1 + t.Length;
-
-		len += " }".Length;
-
-		return len;
-	}
-
-	public override int CalcParamLen()
-	{
-		return ParameterBuilders.Sum(p => p().Length + 2);
-	}
-
-	public override void Render(GeneratedTextTransformation tt, bool isCompact)
-	{
-		WriteMethod(tt, this, isCompact);
-	}
-}
-
-static Action<GeneratedTextTransformation,Attribute> WriteAttribute = (tt,a) =>
-{
-	tt.Write(a.Name);
-
-	if (a.Parameters.Count > 0)
-	{
-		tt.Write("(");
-
-		for (var i = 0; i < a.Parameters.Count; i++)
-		{
-			if (i > 0)
-				if (a.Parameters[i - 1].All(c => c == ' '))
-					tt.Write("  ");
-				else
-					SkipSpacesAndInsert(tt, ", ");
-			tt.Write(a.Parameters[i]);
-		}
-
-		SkipSpacesAndInsert(tt, ")");
-	}
-};
-
-public partial class Attribute
-{
-	public string       Name;
-	public List<string> Parameters = new List<string>();
-	public string       Conditional;
-	public bool         IsSeparated;
-
-	public Attribute()
-	{
-	}
-
-	public Attribute(string name, params string[] ps)
-	{
-		Name = name;
-		Parameters.AddRange(ps);
-	}
-
-	public virtual void Render(GeneratedTextTransformation tt)
-	{
-		WriteAttribute(tt, this);
-	}
-}
-
-// Helpers.
-//
-
-Func<string,string> ToPlural   = s => s + "s";
-Func<string,string> ToSingular = s => s;
-
-static string LenDiff(int max, string str)
-{
-	var s = "";
-
-	while (max-- > str.Length)
-		s += " ";
-
-	return s;
-}
-
-public void WriteSpaces(int len)
-{
-	while (len-- > 0)
-		Write(" ");
-}
-
-void RemoveSpace()
-{
-	Write(" ");
-
-	while (GenerationEnvironment.Length > 0 &&
-		(GenerationEnvironment[GenerationEnvironment.Length - 1] == ' ' ||
-		 GenerationEnvironment[GenerationEnvironment.Length - 1] == '\t'))
-		GenerationEnvironment.Length--;
-}
-
-public static IEnumerable<ITree> GetTreeNodes(ITree parent)
-{
-	foreach (var node in parent.GetNodes())
-	{
-		yield return node;
-
-		foreach (var grandNode in GetTreeNodes(node))
-			yield return grandNode;
-	}
-}
-
-public static ITree FindNode(ITree parent, Func<ITree,bool> func)
-{
-	foreach (var node in parent.GetNodes())
-	{
-		if (func(node))
-			return node;
-
-		var n = FindNode(node, func);
-
-		if (n != null)
-			return n;
-	}
-
-	return null;
-}
-
-static void SkipSpacesAndInsert(GeneratedTextTransformation tt, string value)
-{
-	var l = tt.GenerationEnvironment.Length;
-
-	for (; l > 0 && tt.GenerationEnvironment[l - 1] == ' '; l--)
-	{
-	}
-
-	tt.GenerationEnvironment.Insert(l, value);
-}
-
-
-string ToCamelCase(string name)
-{
-	var n = 0;
-
-	foreach (var c in name)
-	{
-		if (char.IsUpper(c))
-			n++;
-		else
-			break;
-	}
-
-	if (n == 0)
-		return name;
-
-	if (n == name.Length)
-		return name.ToLower();
-
-	n = Math.Max(1, n - 1);
-
-	return name.Substring(0, n).ToLower() + name.Substring(n);
-}
-
-event Action<Property,string,object> SetPropertyValueAction;
-
-void SetPropertyValue(Property propertyObject, string propertyName, object value)
-{
-	if (SetPropertyValueAction != null)
-		SetPropertyValueAction(propertyObject, propertyName, value);
-}
-
-static string ToStringLiteral(string value)
-{
-	if (value == null)
-		return "null";
-
-	var sb = new StringBuilder("\"");
-
-	foreach (var chr in value)
-	{
-		switch (chr)
-		{
-			case '\t':     sb.Append("\\t");            break;
-			case '\n':     sb.Append("\\n");            break;
-			case '\r':     sb.Append("\\r");            break;
-			case '\\':     sb.Append("\\\\");           break;
-			case '"' :     sb.Append("\\\"");           break;
-			case '\0':     sb.Append("\\0");            break;
-			case '\u0085':
-			case '\u2028':
-			case '\u2029':
-					 sb.Append($"\\u{(ushort)chr:X4}"); break;
-			default: sb.Append(chr);                    break;
-		}
-	}
-
-	sb.Append('"');
-
-	return sb.ToString();
-}
-
-public class ModelType
-{
-	private readonly IList<ModelType> _arguments = new List<ModelType>();
-
-	public static ModelType Create<TType>(bool referenceNullable)
-	{
-		return Create(typeof(TType), referenceNullable);
-	}
-
-	public static ModelType Create(Type type, bool referenceNullable)
-	{
-		if (type.IsArray)
-			return Array(Create(type.GetElementType(), false), referenceNullable);
-
-		return new ModelType(type, referenceNullable);
-	}
-
-	public static ModelType Array(ModelType elementType, bool referenceNullable)
-	{
-		return new ModelType(elementType, referenceNullable);
-	}
-
-	public ModelType(Type type, bool nullable, params ModelType[] typeArguments)
-	{
-		if (type.IsConstructedGenericType)
-		{
-			if (typeArguments != null && typeArguments.Length > 0)
-				throw new ArgumentException($"{type} must be open generic type or {typeArguments} should be empty");
-
-			if (!_aliasedTypes.ContainsKey(type))
-				_arguments = new List<ModelType>(type.GetGenericArguments().Select(a => new ModelType(a, /* we don't have type info here */ false)));
-		}
-
-		Type        = type;
-		IsReference = !type.IsValueType;
-		IsNullable  = nullable || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>));
-		if (typeArguments != null && typeArguments.Length > 0)
-			_arguments = new List<ModelType>(typeArguments);
-	}
-
-	public ModelType(string type, bool referenceType, bool isNullable, params ModelType[] typeArguments)
-	{
-		TypeName    = type;
-		IsReference = referenceType;
-		IsNullable  = isNullable;
-
-		if (typeArguments != null && typeArguments.Length > 0)
-			_arguments = new List<ModelType>(typeArguments);
-	}
-
-	// array constructor
-	public ModelType(ModelType elementType, bool isNullable)
-	{
-		ElementType = elementType;
-		IsReference = true;
-		IsNullable  = isNullable;
-		IsArray     = true;
-	}
-
-	public Type      Type        { get; }
-	public string    TypeName    { get; }
-	public ModelType ElementType { get; }
-	public bool      IsReference { get; }
-	public bool      IsNullable  { get; }
-	public bool      IsArray     { get; }
-
-	public IEnumerable<ModelType> Arguments => _arguments ?? System.Array.Empty<ModelType>();
-
-	private static readonly IDictionary<Type, string> _aliasedTypes = new Dictionary<Type, string>()
-	{
-		{ typeof(bool),     "bool" },
-		{ typeof(byte),     "byte" },
-		{ typeof(sbyte),    "sbyte" },
-		{ typeof(char),     "char" },
-		{ typeof(decimal),  "decimal" },
-		{ typeof(double),   "double" },
-		{ typeof(float),    "float" },
-		{ typeof(int),      "int" },
-		{ typeof(uint),     "uint" },
-		{ typeof(long),     "long" },
-		{ typeof(ulong),    "ulong" },
-		{ typeof(object),   "object" },
-		{ typeof(short),    "short" },
-		{ typeof(ushort),   "ushort" },
-		{ typeof(string),   "string" },
-		{ typeof(bool?),    "bool?" },
-		{ typeof(byte?),    "byte?" },
-		{ typeof(sbyte?),   "sbyte?" },
-		{ typeof(char?),    "char?" },
-		{ typeof(decimal?), "decimal?" },
-		{ typeof(double?),  "double?" },
-		{ typeof(float?),   "float?" },
-		{ typeof(int?),     "int?" },
-		{ typeof(uint?),    "uint?" },
-		{ typeof(long?),    "long?" },
-		{ typeof(ulong?),   "ulong?" },
-		{ typeof(short?),   "short?" },
-		{ typeof(ushort?),  "ushort?" }
-	};
-
-	public string ToTypeName()
-	{
-		var sb = new StringBuilder();
-
-		if (TypeName != null)
-			sb.Append(TypeName);
-		else if (Type != null)
-			sb.Append(_aliasedTypes.ContainsKey(Type) ? _aliasedTypes[Type] : (Type.Name.Substring(0, Type.Name.IndexOf('`') < 0 ? Type.Name.Length : Type.Name.IndexOf('`'))));
-		else
-			sb.Append(ElementType.ToTypeName());
-
-		if (_arguments != null && _arguments.Count > 0)
-		{
-			sb.Append("<");
-			sb.Append(string.Join(", ", _arguments.Select(a => a.ToTypeName())));
-			sb.Append(">");
-		}
-
-		if (IsArray)
-			sb.Append("[]");
-
-		if (EnableNullableReferenceTypes && IsReference && IsNullable)
-			sb.Append("?");
-
-		return sb.ToString();
-	}
-}
-
-static bool IsValueTypeDefault(string typeName)
-{
-	switch (typeName)
-	{
-		case "bool":
-		case "bool?":
-		case "char":
-		case "char?":
-		case "decimal":
-		case "decimal?":
-		case "int":
-		case "int?":
-		case "uint":
-		case "uint?":
-		case "byte":
-		case "byte?":
-		case "sbyte":
-		case "sbyte?":
-		case "long":
-		case "long?":
-		case "ulong":
-		case "ulong?":
-		case "short":
-		case "short?":
-		case "ushort":
-		case "ushort?":
-		case "float":
-		case "float?":
-		case "double":
-		case "double?":
-		case "DateTime":
-		case "DateTime?":
-		case "DateTimeOffset":
-		case "DateTimeOffset?":
-		case "TimeSpan":
-		case "TimeSpan?":
-		case "Guid":
-		case "Guid?":
-		case "SqlHierarchyId":
-		case "SqlHierarchyId?":
-		case "NpgsqlDate":
-		case "NpgsqlDate?":
-		case "NpgsqlTimeSpan":
-		case "NpgsqlTimeSpan?":
-		case "NpgsqlPoint":
-		case "NpgsqlPoint?":
-		case "NpgsqlLSeg":
-		case "NpgsqlLSeg?":
-		case "NpgsqlBox":
-		case "NpgsqlBox?":
-		case "NpgsqlPath":
-		case "NpgsqlPath?":
-		case "NpgsqlPolygon":
-		case "NpgsqlPolygon?":
-		case "NpgsqlCircle":
-		case "NpgsqlCircle?":
-		case "NpgsqlLine":
-		case "NpgsqlLine?":
-		case "NpgsqlInet":
-		case "NpgsqlInet?":
-		case "NpgsqlDateTime":
-		case "NpgsqlDateTime?":
-			return true;
-		case "object":
-		case "string":
-		case "byte[]":
-		case "BitArray":
-		case "SqlGeography":
-		case "SqlGeometry":
-		case "PhysicalAddress":
-		case "Array":
-		case "DataTable":
-			return false;
-	}
-
-	return typeName.EndsWith("?");
-}
-
-#>
diff --git a/src/Database.T4/LinqToDB.Templates/Validation.ttinclude b/src/Database.T4/LinqToDB.Templates/Validation.ttinclude
deleted file mode 100644
index 3715c7e46af20ec3af4142bff61db26df8e14581..0000000000000000000000000000000000000000
--- a/src/Database.T4/LinqToDB.Templates/Validation.ttinclude
+++ /dev/null
@@ -1,191 +0,0 @@
-<#
-	{
-		var beforeGenerateModel = BeforeGenerateModel;
-		BeforeGenerateModel = () =>
-		{
-			beforeGenerateModel();
-			ValidationImpl();
-		};
-	}
-#>
-<#+
-void ValidationImpl()
-{
-	foreach (Class cl in GetTreeNodes(Model).OfType<Class>())
-	{
-		var validationGroup = new MemberGroup
-		{
-			Region = "Validation",
-		};
-
-		var props = GetTreeNodes(cl).OfType<Property>().Where(p => p.CustomValidation).ToList();
-
-		if (props.Count > 0)
-		{
-			if (!Model.Usings.Contains("System.Collections.Generic"))
-			{
-				Model.Usings.Add("System.Collections.Generic");
-			}
-
-			var isValid      = new Method(() => "bool", "IsValid", new Func<string>[] { () => cl.Name + " obj" }) { IsStatic = true };
-			var validator    = new Class("CustomValidator", isValid) { IsStatic = true, };
-			var partialGroup = new MemberGroup { IsCompact = true };
-
-			validationGroup.Members.Add(new Field(() => "int", "_isValidCounter") { Attributes = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } } });
-			validationGroup.Members.Add(validator);
-			validationGroup.Members.Add(partialGroup);
-
-			isValid.BodyBuilders.Add(() => new []
-			{
-				"try",
-				"{",
-				"\tobj._isValidCounter++;",
-				""
-			});
-
-			var ret = "\treturn ";
-
-			for (var idx = 0; idx < props.Count; idx++)
-			{
-				var i = idx;
-				var p = props[i];
-
-				var name  = p.Name.Trim();
-				var mname = "Validate" + name;
-
-				cl.Attributes.Add(
-					new Attribute("CustomValidation",
-						"typeof(" + cl.Name + ".CustomValidator)",
-						ToStringLiteral(mname))
-						{
-							IsSeparated = true
-						});
-
-				isValid.BodyBuilders.Add(() => new [] {
-					"\tvar flag" + i + " = ValidationResult.Success == " + mname + "(obj, obj." + name + ");" });
-
-				ret += (i == 0 ? "" : " || ") + "flag" + i;
-
-				var validate = new Method(() => "ValidationResult", mname,
-					new Func<string>[] { () => cl.Name + " obj", () => p.BuildType().Trim() + " value" }) { IsStatic = true };
-
-				validate.BodyBuilders.Add(() => new []
-				{
-					"var list = new List<ValidationResult>();",
-					"",
-					"Validator.TryValidateProperty(",
-					"\tvalue,",
-					"\tnew ValidationContext(obj, null, null) { MemberName = NameOf" + name + " }, list);",
-					"",
-					"obj." + mname + "(value, list);",
-					"",
-					"if (list.Count > 0)",
-					"{",
-					"\tforeach (var result in list)",
-					"\t\tforeach (var name in result.MemberNames)",
-					"\t\t\tobj.AddError(name, result.ErrorMessage);",
-					"",
-					"\treturn list[0];",
-					"}",
-					"",
-					"obj.RemoveError(NameOf" + name + ");",
-					"",
-					"return ValidationResult.Success;"
-				});
-
-				validator.Members.Add(validate);
-
-				partialGroup.Members.Add(new Method(
-					() => "void",
-					mname,
-					new Func<string>[]
-					{
-						() => p.BuildType().Trim() + " value",
-						() => "List<ValidationResult> validationResults",
-					})
-					{
-						AccessModifier = AccessModifier.Partial,
-					});
-			}
-
-			isValid.BodyBuilders.Add(() => new []
-			{
-				"",
-				ret + ";",
-				"}",
-				"finally",
-				"{",
-				"\tobj._isValidCounter--;",
-				"}"
-			});
-		}
-
-		props = GetTreeNodes(cl).OfType<Property>().Where(p => p.ValidateProperty && p.HasSetter).ToList();
-
-		if (props.Count > 0)
-		{
-			foreach (var p in props)
-			{
-				var setBody = p.BuildSetBody().ToList();
-				if (setBody.Count > 0)
-					setBody.Insert(0, "");
-
-				setBody.Insert(0, "if (_validationLockCounter == 0)");
-				setBody.Insert(1, "{");
-
-				if (p.CustomValidation)
-				{
-					setBody.Insert(2, "\tvar validationResult = CustomValidator.Validate" + p.Name.Trim() + "(this, value);");
-					setBody.Insert(3, "\tif (validationResult != ValidationResult.Success)");
-					setBody.Insert(4, "\t\tthrow new ValidationException(validationResult, null, null);");
-					setBody.Insert(5, "}");
-				}
-				else
-				{
-					setBody.Insert(2, "\tValidator.ValidateProperty(");
-					setBody.Insert(3, "\t\tvalue,");
-					setBody.Insert(4, string.Format("\t\tnew ValidationContext(this, null, null) {{ MemberName = NameOf{0} }});", p.Name.Trim()));
-					setBody.Insert(5, "}");
-				}
-
-				p.SetBodyBuilders.Clear();
-				p.SetBodyBuilders.Add(() => setBody.ToArray());
-			}
-
-			validationGroup.Members.Add(new Field(() => "int", "_validationLockCounter")
-			{
-				AccessModifier = AccessModifier.Private,
-				InitValue      = "0",
-				Attributes     = { new Attribute("field : NonSerialized") { Conditional = "!SILVERLIGHT" } }
-			});
-
-			validationGroup.Members.Add(new Method (() => "void", "LockValidation",   null, () => new[] { "_validationLockCounter++;" }));
-			validationGroup.Members.Add(new Method (() => "void", "UnlockValidation", null, () => new[] { "_validationLockCounter--;" }));
-		}
-
-		if (validationGroup.Members.Count > 0)
-		{
-			if (!Model.Usings.Contains("System.ComponentModel.DataAnnotations"))
-				Model.Usings.Add("System.ComponentModel.DataAnnotations");
-
-			cl.Members.Add(validationGroup);
-			cl.SetTree();
-		}
-	}
-}
-
-partial class Property
-{
-	public bool CustomValidation;
-	public bool ValidateProperty;
-
-	public bool Validate
-	{
-		set
-		{
-			CustomValidation = value;
-			ValidateProperty = value;
-		}
-	}
-}
-#>
diff --git a/src/Database.T4/Properties/AssemblyInfo.cs b/src/Database.T4/Properties/AssemblyInfo.cs
deleted file mode 100644
index 7f715346a07dc077d98eac1bf86b10185472e8a4..0000000000000000000000000000000000000000
--- a/src/Database.T4/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by Cake.
-// </auto-generated>
-//------------------------------------------------------------------------------
-using System.Reflection;
-
-[assembly: AssemblyTitle("Database.T4")]
-[assembly: AssemblyDescription("Database.T4 is a part of the CoScInE group.")]
-[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
-[assembly: AssemblyProduct("Database.T4")]
-[assembly: AssemblyVersion("1.27.0")]
-[assembly: AssemblyFileVersion("1.27.0")]
-[assembly: AssemblyInformationalVersion("1.27.0-product-1154-res0002")]
-[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
-
diff --git a/src/Database.T4/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest b/src/Database.T4/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
deleted file mode 100644
index 47bd4a04ac271f3c4ad2d7a4898b776c8ccf9ec6..0000000000000000000000000000000000000000
--- a/src/Database.T4/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-    <noInheritable></noInheritable>
-    <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
-    <file name="msvcr90.dll" hashalg="SHA1" hash="1b065fdf0cb8516b0553128eae4af39c5f8eeb46"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>Vy8CgQgbu3qH5JHTK0op4kR8114=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90.dll" hashalg="SHA1" hash="45d3027d87eade77317e92994790598c755b3920"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>QTJu3Gttpt8hhCktGelNeXj4Yp8=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90.dll" hashalg="SHA1" hash="e77fd69f7c88f34329d8a95c3179f67ead330217"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>1ruqF7/L+m1tqnJVscaOtNRNHIE=</dsig:DigestValue></asmv2:hash></file>
-</assembly>
\ No newline at end of file
diff --git a/src/Database.T4/amd64/Microsoft.VC90.CRT/README_ENU.txt b/src/Database.T4/amd64/Microsoft.VC90.CRT/README_ENU.txt
deleted file mode 100644
index fc38b3684fbe06e056c123e9ff6f576f842c8b69..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/Microsoft.VC90.CRT/README_ENU.txt and /dev/null differ
diff --git a/src/Database.T4/amd64/Microsoft.VC90.CRT/msvcr90.dll b/src/Database.T4/amd64/Microsoft.VC90.CRT/msvcr90.dll
deleted file mode 100644
index c95e1bf213f99ca8c602a8c7dd33223215328fdb..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/Microsoft.VC90.CRT/msvcr90.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlceca40.dll b/src/Database.T4/amd64/sqlceca40.dll
deleted file mode 100644
index d5d4c2044822b6c8ccb38c4086411d668fe5a0df..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlceca40.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlcecompact40.dll b/src/Database.T4/amd64/sqlcecompact40.dll
deleted file mode 100644
index ed061adee6683c2c5beb3fba60603617fc143275..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlcecompact40.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlceer40EN.dll b/src/Database.T4/amd64/sqlceer40EN.dll
deleted file mode 100644
index e19eed9bda9a4230b54d4e182426970e9985a03f..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlceer40EN.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlceme40.dll b/src/Database.T4/amd64/sqlceme40.dll
deleted file mode 100644
index c67fc9e6a5368b86cad0a83d7ba1ad5269ee4119..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlceme40.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlceqp40.dll b/src/Database.T4/amd64/sqlceqp40.dll
deleted file mode 100644
index df4440332dcec0ae168e1ac04fa26394624d7f6d..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlceqp40.dll and /dev/null differ
diff --git a/src/Database.T4/amd64/sqlcese40.dll b/src/Database.T4/amd64/sqlcese40.dll
deleted file mode 100644
index af2de5ec908ecff44965194fd70e4b782bcf69cf..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/amd64/sqlcese40.dll and /dev/null differ
diff --git a/src/Database.T4/app.config b/src/Database.T4/app.config
deleted file mode 100644
index cc9d4ebe2829756614748d7b0c2b17175fa1f4de..0000000000000000000000000000000000000000
--- a/src/Database.T4/app.config
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-  <runtime>
-    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-      <dependentAssembly>
-        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-    </assemblyBinding>
-  </runtime>
-</configuration>
\ No newline at end of file
diff --git a/src/Database.T4/packages.config b/src/Database.T4/packages.config
deleted file mode 100644
index 733a6e2b28e0b068eff2e96bd3c4bb99550fffb5..0000000000000000000000000000000000000000
--- a/src/Database.T4/packages.config
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="Consul" version="1.6.1.1" targetFramework="net461" />
-  <package id="Coscine.Configuration" version="1.6.0" targetFramework="net461" />
-  <package id="Coscine.Database.Helpers" version="1.2.0" targetFramework="net461" />
-  <package id="Coscine.Migrations" version="1.11.0" targetFramework="net461" />
-  <package id="FluentMigrator" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Abstractions" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.Oracle" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.Postgres" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.SqlAnywhere" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.SqlServer" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Core" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Db2" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Firebird" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Hana" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Jet" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.MySql" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Oracle" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Postgres" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Redshift" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlAnywhere" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SQLite" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlServer" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlServerCe" version="3.2.11" targetFramework="net461" />
-  <package id="linq2db" version="3.1.0" targetFramework="net461" />
-  <package id="linq2db.SqlServer" version="3.1.0" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net461" />
-  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Logging" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Options" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Primitives" version="2.0.0" targetFramework="net461" />
-  <package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net461" />
-  <package id="System.ComponentModel.Annotations" version="4.4.1" targetFramework="net461" />
-  <package id="System.Data.SqlClient" version="4.8.2" targetFramework="net461" />
-  <package id="System.Runtime.CompilerServices.Unsafe" version="4.4.0" targetFramework="net461" />
-  <package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
-</packages>
\ No newline at end of file
diff --git a/src/Database.T4/runtimes/win-arm/native/e_sqlite3.dll b/src/Database.T4/runtimes/win-arm/native/e_sqlite3.dll
deleted file mode 100644
index 4ab44c0d1194ccc71afb8f92aef018c8495952e2..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/runtimes/win-arm/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.T4/runtimes/win-x64/native/e_sqlite3.dll b/src/Database.T4/runtimes/win-x64/native/e_sqlite3.dll
deleted file mode 100644
index fee89528e5b18f17353cd2d9ab91e7e89a830208..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/runtimes/win-x64/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.T4/runtimes/win-x86/native/e_sqlite3.dll b/src/Database.T4/runtimes/win-x86/native/e_sqlite3.dll
deleted file mode 100644
index 3cbd9eb1e4d43b1904e4d4cf073357fbb406847d..0000000000000000000000000000000000000000
Binary files a/src/Database.T4/runtimes/win-x86/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.Tests/Database.Tests.csproj b/src/Database.Tests/Database.Tests.csproj
index a2d9beeee46c6854fe48485cf12c271e5fac7621..791358757fca72d26e64a9c839466f7c0bfe42ba 100644
--- a/src/Database.Tests/Database.Tests.csproj
+++ b/src/Database.Tests/Database.Tests.csproj
@@ -1,229 +1,21 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" />
-  <Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{2A5D0EC8-E487-4B43-A311-05852464ED01}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Coscine.Database.Tests</RootNamespace>
-    <AssemblyName>Coscine.Database.Tests</AssemblyName>
-    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <NuGetPackageImportStamp>
-    </NuGetPackageImportStamp>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Consul, Version=1.6.1.1, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
-      <HintPath>..\packages\Consul.1.6.1.1\lib\net461\Consul.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Configuration, Version=1.6.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Configuration.1.6.0\lib\net461\Coscine.Configuration.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Database.Helpers, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Database.Helpers.1.2.0\lib\net461\Coscine.Database.Helpers.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Migrations, Version=1.11.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Migrations.1.11.0\lib\net461\Coscine.Migrations.dll</HintPath>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="FluentMigrator, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.3.2.11\lib\net461\FluentMigrator.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Abstractions, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Abstractions.3.2.11\lib\net461\FluentMigrator.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Oracle.3.2.11\lib\net461\FluentMigrator.Extensions.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Postgres.3.2.11\lib\net461\FluentMigrator.Extensions.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Extensions.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlServer.3.2.11\lib\net461\FluentMigrator.Extensions.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.3.2.11\lib\net461\FluentMigrator.Runner.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Core, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Core.3.2.11\lib\net461\FluentMigrator.Runner.Core.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Db2, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Db2.3.2.11\lib\net461\FluentMigrator.Runner.Db2.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Firebird, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Firebird.3.2.11\lib\net461\FluentMigrator.Runner.Firebird.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Hana, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Hana.3.2.11\lib\net461\FluentMigrator.Runner.Hana.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Jet, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Jet.3.2.11\lib\net461\FluentMigrator.Runner.Jet.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.MySql, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.MySql.3.2.11\lib\net461\FluentMigrator.Runner.MySql.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Oracle.3.2.11\lib\net461\FluentMigrator.Runner.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Postgres.3.2.11\lib\net461\FluentMigrator.Runner.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Redshift, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Redshift.3.2.11\lib\net461\FluentMigrator.Runner.Redshift.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Runner.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SQLite, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SQLite.3.2.11\lib\net461\FluentMigrator.Runner.SQLite.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServer.3.2.11\lib\net461\FluentMigrator.Runner.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServerCe, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\lib\net461\FluentMigrator.Runner.SqlServerCe.dll</HintPath>
-    </Reference>
-    <Reference Include="linq2db, Version=3.1.1.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
-      <HintPath>..\packages\linq2db.3.1.1\lib\net46\linq2db.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Data.Sqlite, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Data.Sqlite.Core.5.0.2\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Options, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Options.2.0.1\lib\netstandard2.0\Microsoft.Extensions.Options.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Primitives, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Primitives.2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath>
-    </Reference>
-    <Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
-      <HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ComponentModel.Annotations.4.4.1\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.DataAnnotations" />
-    <Reference Include="System.Configuration" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SqlClient.4.8.2\lib\net461\System.Data.SqlClient.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Net.Http.WebRequest" />
-    <Reference Include="System.Numerics" />
-    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.4.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
-      <Private>True</Private>
-      <Private>True</Private>
-    </Reference>
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Migrations\Migration333301010000_SampleMigrationUsers.cs" />
-    <Compile Include="ModelTests.cs" />
-    <Compile Include="Migrations\Migration333301010001_SampleMigrationProjects.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="TestCoscineDB.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="app.config" />
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <WCFMetadata Include="Connected Services\" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Database\Database.csproj">
-      <Project>{a7369ea1-f9ab-49d2-bdb1-c3facd37bbd0}</Project>
-      <Name>Database</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
-    <Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props'))" />
-    <Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
-    <Error Condition="!Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets'))" />
-  </Target>
-  <Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
-  <Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
+<Project Sdk="Microsoft.NET.Sdk">
+	<PropertyGroup>
+		<OutputType>Library</OutputType>
+		<RootNamespace>Coscine.Database.Tests</RootNamespace>
+		<AssemblyName>Coscine.Database.Tests</AssemblyName>
+		<TargetFrameworks>net5.0;net461</TargetFrameworks>
+		<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+	</PropertyGroup>
+	<ItemGroup>
+		<ProjectReference Include="..\Database\Database.csproj" />
+	</ItemGroup>
+	<ItemGroup>
+		<PackageReference Include="Coscine.Configuration" Version="2.*-*" />
+		<PackageReference Include="Coscine.Database.Helpers" Version="2.*-*" />
+		<PackageReference Include="Coscine.Migrations" Version="2.*-*" />
+		<PackageReference Include="linq2db" Version="3.2.3" />
+		<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
+		<PackageReference Include="NUnit" Version="3.13.1" />
+		<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
+	</ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/src/Database.Tests/HelperTests.cs b/src/Database.Tests/HelperTests.cs
deleted file mode 100644
index cfa71a46f1774f56e33904b2e4090943eca3a7b8..0000000000000000000000000000000000000000
--- a/src/Database.Tests/HelperTests.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using Coscine.Configuration;
-using Coscine.Database.Helpers;
-using Coscine.Database.Settings;
-using LinqToDB.Data;
-using NUnit.Framework;
-using System;
-
-namespace Coscine.Database.Tests
-{
-    [TestFixture]
-    public class HelperTests
-    {
-        private DatabaseMasterHelper _helper;
-        private string _databaseName;
-
-        [OneTimeSetUp]
-        public void OneTimeSetUp()
-        {
-            _databaseName = $"Coscine_Database.Tests_{Guid.NewGuid()}";
-
-            var settings = new ConsulConnectionSettings() { Configuration = new ConsulConfiguration() };
-
-            settings.LoadSettingsFromConsul();
-            settings.Database = _databaseName;
-
-            _helper = new DatabaseMasterHelper
-            {
-                ConnectionSettings = settings
-            };
-
-            DataConnection.DefaultSettings = new CoscineTestingSettings { DatabaseName = _databaseName };
-        }
-
-        [OneTimeTearDown]
-        public void OneTimeTearDown()
-        {
-            if (_helper.DatabaseExists(_databaseName))
-            {
-                _helper.KillConnectionsToDatabase(_databaseName);
-                _helper.DropDatabase(_databaseName);
-            }
-        }
-
-        [Test]
-        public void CreateDropDatabase()
-        {
-            Assert.IsFalse(_helper.DatabaseExists(_databaseName));
-            _helper.EnsureDatabase(_helper.ConnectionSettings.Database);
-            Assert.IsTrue(_helper.DatabaseExists(_databaseName));
-            _helper.KillConnectionsToDatabase(_databaseName);
-            _helper.DropDatabase(_databaseName);
-            Assert.IsFalse(_helper.DatabaseExists(_databaseName));
-        }
-    }
-}
diff --git a/src/Database.Tests/Migrations/Migration333301010000_SampleMigrationUsers.cs b/src/Database.Tests/Migrations/Migration333301010000_SampleMigrationUsers.cs
deleted file mode 100644
index b0735771e780ff7e618789f9c0afa378444c8925..0000000000000000000000000000000000000000
--- a/src/Database.Tests/Migrations/Migration333301010000_SampleMigrationUsers.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FluentMigrator;
-
-namespace Coscine.Database.Tests.Migrations
-{
-    [Migration(333301010000)]
-    public class Migration333301010000_SampleMigrationUsers : Migration
-    {
-        public override void Up()
-        {
-            Create.Table("TestUsers")
-                .WithColumn("UserId").AsInt32().NotNullable().PrimaryKey().Identity()
-                .WithColumn("UserName").AsString(255).NotNullable().WithDefaultValue("Anonymous");
-
-            Insert.IntoTable("TestUsers").Row(new { UserName = "user1" });
-            Insert.IntoTable("TestUsers").Row(new { UserName = "user2" });
-            Insert.IntoTable("TestUsers").Row(new { UserName = "user3" });
-        }
-
-        public override void Down()
-        {
-            Delete.Table("TestUsers");
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Database.Tests/Migrations/Migration333301010001_SampleMigrationProjects.cs b/src/Database.Tests/Migrations/Migration333301010001_SampleMigrationProjects.cs
deleted file mode 100644
index d226421e52a840a234c3334e35f95fc16cc417d9..0000000000000000000000000000000000000000
--- a/src/Database.Tests/Migrations/Migration333301010001_SampleMigrationProjects.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using FluentMigrator;
-
-namespace Coscine.Database.Tests.Migrations
-{
-    [Migration(333301010001)]
-    public class Migration333301010001_SampleMigrationProjects : Migration
-    {
-        public override void Up()
-        {
-            Create.Table("TestProjects")
-                .WithColumn("ProjectId").AsInt32().NotNullable().PrimaryKey().Identity()
-                .WithColumn("ProjectName").AsString(255).NotNullable().WithDefaultValue("Anonymous");
-
-            Insert.IntoTable("TestProjects").Row(new { ProjectName = "project2" });
-            Insert.IntoTable("TestProjects").Row(new { ProjectName = "project3" });
-            Insert.IntoTable("TestProjects").Row(new { ProjectName = "project1" });
-        }
-
-        public override void Down()
-        {
-            Delete.Table("TestProjects");
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Database.Tests/ModelTests.cs b/src/Database.Tests/ModelTests.cs
index 441b5190577b1779fdf2564d03e794478b2c5f4f..c271ca85f7cfc2fd0bea4b725f5d7a960e729d37 100644
--- a/src/Database.Tests/ModelTests.cs
+++ b/src/Database.Tests/ModelTests.cs
@@ -1,134 +1,60 @@
-using Coscine.Configuration;
-using Coscine.Database.Helpers;
-using Coscine.Database.Settings;
-using Coscine.Database.Tests.Migrations;
-using Coscine.Migrations;
-using LinqToDB;
-using LinqToDB.Data;
-using NUnit.Framework;
+using NUnit.Framework;
 using System;
-using System.Linq;
 
 namespace Coscine.Database.Tests
 {
     [TestFixture]
     public class ModelTests
     {
-        private CoscineMigrations _migrator;
-        private DatabaseMasterHelper _helper;
-        private string _databaseName;
-
-        [OneTimeSetUp]
-        public void OneTimeSetUp()
-        {
-            _databaseName = $"Coscine_Migrations.Tests_{Guid.NewGuid()}";
-
-            var settings = new ConfigurationConnectionSettings() { Configuration = new ConsulConfiguration() };
-
-            settings.LoadSettingsFromConfiguration();
-            settings.Database = _databaseName;
-
-            _migrator = new CoscineMigrations
-            {
-                TargetAssembly = typeof(Migration333301010000_SampleMigrationUsers).Assembly,
-                ConnectionSettings = settings
-            };
-
-            _helper = new DatabaseMasterHelper
-            {
-                ConnectionSettings = settings
-            };
-
-            _helper.EnsureDatabase(_migrator.ConnectionSettings.Database);
-
-            DataConnection.DefaultSettings = new CoscineTestingSettings { DatabaseName = _databaseName };
-        }
-
-        [OneTimeTearDown]
-        public void OneTimeTearDown()
-        {
-            if (_helper.DatabaseExists(_databaseName))
-            {
-                _helper.KillConnectionsToDatabase(_databaseName);
-                _helper.DropDatabase(_databaseName);
-            }
-        }
-
-        [SetUp]
-        public void Setup()
-        {
-            _migrator.MigrateUp();
-        }
-
-        [TearDown]
-        public void TearDown()
-        {
-            _migrator.RollBack(2);
-        }
-
-        [Test]
-        public void TestRead()
-        {
-            using (var db = new TestCoscineDb())
-            {
-                var q =
-                    from p in db.TestUsers
-                    select p;
-
-                Assert.True(q.Any(e => e.UserId == 1));
-                Assert.True(q.Count() == 3);
-            }
-        }
-
-        [Test]
-        public void TestInsert()
-        {
-            using (var db = new TestCoscineDb())
-            {
-                db.TestProjects
-                    .Value(p => p.ProjectName, "project4")
-                    .Insert();
-                var q2 =
-                    from c in db.TestProjects
-                    select c;
-
-                Assert.True(q2.Count() == 4);
-                Assert.True(q2.Any(e => e.ProjectId == 4));
-            }
-        }
-
+        private static string _databaseName;
+        //    private IConfiguration _configuration;
+        //    private static Guid _userId;
+
+        //    [OneTimeSetUp]
+        //    public void OneTimeSetUp()
+        //    {
+        //        // Collect the DatabaseName from the Script $env:DatabaseName=
+        //        _databaseName = Environment.GetEnvironmentVariable("DatabaseName");
+        //        _configuration = new ConsulConfiguration();
+        //        DatabaseSettingsConfiguration settingsConfiguration = new DatabaseSettingsConfiguration(_configuration);
+        //        settingsConfiguration.DatabaseName = _databaseName;
+        //        CoscineDB.DatabaseSettingsConfiguration = settingsConfiguration;
+        //    }
+
+        //    [Test]
+        //    public void TestRead()
+        //    {
+        //        // HOW TO EXECUTE SECOND?
+        //        var abc = new UserModel().GetAll();
+        //    }
+
+        //    [Test]
+        //    public void TestAdd()
+        //    {
+        //        // HOW TO EXECUTE FIRST?
+        //        User testUser = new User()
+        //        {
+        //            Id = Guid.NewGuid(),
+        //            DisplayName = "EF_TEST_DISPLAY_NAME",
+        //            Givenname = "EF_TEST_GIVEN_NAME",
+        //            Surname = "EF_TEST_SURNAME"
+        //        };
+        //        UserModel testUserModel = new UserModel();
+        //        testUserModel.Insert(testUser);
+        //        _userId = testUser.Id;
+        //    }
+
+        //    [Test]
+        //    public void TestRemove()
+        //    {
+        //        // EXECUTE LAST; Delete created Test User in TestAdd().
+        //    }
+        //}
         [Test]
-        public void TestDelete()
+        public void TestCollectFromEnvironment()
         {
-            using (var db = new TestCoscineDb())
-            {
-                db.TestUsers
-                    .Where(p => p.UserId == 3)
-                    .Delete();
-
-                var q1 =
-                    from p in db.TestUsers
-                    select p;
-
-                Assert.True(q1.Count() == 2);
-                Assert.False(q1.Any(e => e.UserId == 3));
-            }
-        }
-
-        [Test]
-        public void TestJoin()
-        {
-            using (var db = new TestCoscineDb())
-            {
-                var q =
-                    from u in db.TestUsers
-                    from p in db.TestProjects.Where(proj => proj.ProjectId == u.UserId)
-                    where u.UserId == 1
-                    select new { uid = u.UserId, pname = p.ProjectName };
-
-                Assert.True(q.All(e => e.uid == 1));
-                Assert.True(q.All(e => e.pname == "project2"));
-            }
+            _databaseName = Environment.GetEnvironmentVariable("DatabaseName");
+            Assert.True(_databaseName.Length > 0);
         }
     }
 }
diff --git a/src/Database.Tests/Properties/AssemblyInfo.cs b/src/Database.Tests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 60af1e576a61196977ad441f03779a090197857f..0000000000000000000000000000000000000000
--- a/src/Database.Tests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by Cake.
-// </auto-generated>
-//------------------------------------------------------------------------------
-using System.Reflection;
-
-[assembly: AssemblyTitle("Database.Tests")]
-[assembly: AssemblyDescription("Database.Tests is a part of the CoScInE group.")]
-[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
-[assembly: AssemblyProduct("Database.Tests")]
-[assembly: AssemblyVersion("1.27.0")]
-[assembly: AssemblyFileVersion("1.27.0")]
-[assembly: AssemblyInformationalVersion("1.27.0-product-1154-res0002")]
-[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
-
diff --git a/src/Database.Tests/TestCoscineDB.cs b/src/Database.Tests/TestCoscineDB.cs
deleted file mode 100644
index c3a955d0988423f0da2267a2c33b1260fd859427..0000000000000000000000000000000000000000
--- a/src/Database.Tests/TestCoscineDB.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using LinqToDB;
-using LinqToDB.Mapping;
-
-namespace Coscine.Database.Tests
-{
-    public class TestCoscineDb : LinqToDB.Data.DataConnection
-    {
-        public ITable<TestProject> TestProjects { get => GetTable<TestProject>(); }
-        public ITable<TestUser> TestUsers { get => GetTable<TestUser>(); }
-    }
-
-    [Table(Schema = "dbo", Name = "TestProjects")]
-    public partial class TestProject
-    {
-        [PrimaryKey, Identity] public int ProjectId { get; set; } // int
-        [Column, NotNull] public string ProjectName { get; set; } // nvarchar(255)
-    }
-
-    [Table(Schema = "dbo", Name = "TestUsers")]
-    public partial class TestUser
-    {
-        [PrimaryKey, Identity] public int UserId { get; set; } // int
-        [Column, NotNull] public string UserName { get; set; } // nvarchar(255)
-    }
-}
\ No newline at end of file
diff --git a/src/Database.Tests/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest b/src/Database.Tests/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
deleted file mode 100644
index 47bd4a04ac271f3c4ad2d7a4898b776c8ccf9ec6..0000000000000000000000000000000000000000
--- a/src/Database.Tests/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-    <noInheritable></noInheritable>
-    <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
-    <file name="msvcr90.dll" hashalg="SHA1" hash="1b065fdf0cb8516b0553128eae4af39c5f8eeb46"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>Vy8CgQgbu3qH5JHTK0op4kR8114=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90.dll" hashalg="SHA1" hash="45d3027d87eade77317e92994790598c755b3920"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>QTJu3Gttpt8hhCktGelNeXj4Yp8=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90.dll" hashalg="SHA1" hash="e77fd69f7c88f34329d8a95c3179f67ead330217"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>1ruqF7/L+m1tqnJVscaOtNRNHIE=</dsig:DigestValue></asmv2:hash></file>
-</assembly>
\ No newline at end of file
diff --git a/src/Database.Tests/amd64/Microsoft.VC90.CRT/README_ENU.txt b/src/Database.Tests/amd64/Microsoft.VC90.CRT/README_ENU.txt
deleted file mode 100644
index fc38b3684fbe06e056c123e9ff6f576f842c8b69..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/Microsoft.VC90.CRT/README_ENU.txt and /dev/null differ
diff --git a/src/Database.Tests/amd64/Microsoft.VC90.CRT/msvcr90.dll b/src/Database.Tests/amd64/Microsoft.VC90.CRT/msvcr90.dll
deleted file mode 100644
index c95e1bf213f99ca8c602a8c7dd33223215328fdb..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/Microsoft.VC90.CRT/msvcr90.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlceca40.dll b/src/Database.Tests/amd64/sqlceca40.dll
deleted file mode 100644
index d5d4c2044822b6c8ccb38c4086411d668fe5a0df..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlceca40.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlcecompact40.dll b/src/Database.Tests/amd64/sqlcecompact40.dll
deleted file mode 100644
index ed061adee6683c2c5beb3fba60603617fc143275..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlcecompact40.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlceer40EN.dll b/src/Database.Tests/amd64/sqlceer40EN.dll
deleted file mode 100644
index e19eed9bda9a4230b54d4e182426970e9985a03f..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlceer40EN.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlceme40.dll b/src/Database.Tests/amd64/sqlceme40.dll
deleted file mode 100644
index c67fc9e6a5368b86cad0a83d7ba1ad5269ee4119..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlceme40.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlceqp40.dll b/src/Database.Tests/amd64/sqlceqp40.dll
deleted file mode 100644
index df4440332dcec0ae168e1ac04fa26394624d7f6d..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlceqp40.dll and /dev/null differ
diff --git a/src/Database.Tests/amd64/sqlcese40.dll b/src/Database.Tests/amd64/sqlcese40.dll
deleted file mode 100644
index af2de5ec908ecff44965194fd70e4b782bcf69cf..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/amd64/sqlcese40.dll and /dev/null differ
diff --git a/src/Database.Tests/app.config b/src/Database.Tests/app.config
deleted file mode 100644
index 263260f1506437a59128e11e130b1bdb3325e463..0000000000000000000000000000000000000000
--- a/src/Database.Tests/app.config
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-  <runtime>
-    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-      <dependentAssembly>
-        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
-      </dependentAssembly>
-    </assemblyBinding>
-  </runtime>
-</configuration>
\ No newline at end of file
diff --git a/src/Database.Tests/packages.config b/src/Database.Tests/packages.config
deleted file mode 100644
index 33eacaa3aba08b532993da963d096fee80aca4b8..0000000000000000000000000000000000000000
--- a/src/Database.Tests/packages.config
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="Consul" version="1.6.1.1" targetFramework="net461" />
-  <package id="Coscine.Configuration" version="1.6.0" targetFramework="net461" />
-  <package id="Coscine.Database.Helpers" version="1.2.0" targetFramework="net461" />
-  <package id="Coscine.Migrations" version="1.11.0" targetFramework="net461" />
-  <package id="FluentMigrator" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Abstractions" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.Oracle" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.Postgres" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.SqlAnywhere" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Extensions.SqlServer" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Core" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Db2" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Firebird" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Hana" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Jet" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.MySql" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Oracle" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Postgres" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.Redshift" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlAnywhere" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SQLite" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlServer" version="3.2.11" targetFramework="net461" />
-  <package id="FluentMigrator.Runner.SqlServerCe" version="3.2.11" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net461" />
-  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Logging" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Options" version="2.0.1" targetFramework="net461" />
-  <package id="Microsoft.Extensions.Primitives" version="2.0.0" targetFramework="net461" />
-  <package id="NUnit" version="3.12.0" targetFramework="net461" />
-  <package id="NUnit3TestAdapter" version="3.17.0" targetFramework="net461" />
-  <package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net461" />
-  <package id="System.ComponentModel.Annotations" version="4.4.1" targetFramework="net461" />
-  <package id="System.Data.SqlClient" version="4.8.2" targetFramework="net461" />
-  <package id="System.Runtime.CompilerServices.Unsafe" version="4.4.0" targetFramework="net461" />
-  <package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
-</packages>
\ No newline at end of file
diff --git a/src/Database.Tests/runtimes/win-arm/native/e_sqlite3.dll b/src/Database.Tests/runtimes/win-arm/native/e_sqlite3.dll
deleted file mode 100644
index 4ab44c0d1194ccc71afb8f92aef018c8495952e2..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/runtimes/win-arm/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.Tests/runtimes/win-x64/native/e_sqlite3.dll b/src/Database.Tests/runtimes/win-x64/native/e_sqlite3.dll
deleted file mode 100644
index fee89528e5b18f17353cd2d9ab91e7e89a830208..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/runtimes/win-x64/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.Tests/runtimes/win-x86/native/e_sqlite3.dll b/src/Database.Tests/runtimes/win-x86/native/e_sqlite3.dll
deleted file mode 100644
index 3cbd9eb1e4d43b1904e4d4cf073357fbb406847d..0000000000000000000000000000000000000000
Binary files a/src/Database.Tests/runtimes/win-x86/native/e_sqlite3.dll and /dev/null differ
diff --git a/src/Database.sln b/src/Database.sln
index 4a03032ecc8c6f247ee71f333cdb3ed6e39d5d10..8873848345dc4c6de76486c167f126a46b5945f6 100644
--- a/src/Database.sln
+++ b/src/Database.sln
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio Version 16
 VisualStudioVersion = 16.0.29009.5
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database", "Database\Database.csproj", "{A7369EA1-F9AB-49D2-BDB1-C3FACD37BBD0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database", "Database\Database.csproj", "{A7369EA1-F9AB-49D2-BDB1-C3FACD37BBD0}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database.Tests", "Database.Tests\Database.Tests.csproj", "{2A5D0EC8-E487-4B43-A311-05852464ED01}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database.Tests", "Database.Tests\Database.Tests.csproj", "{2A5D0EC8-E487-4B43-A311-05852464ED01}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database.T4", "Database.T4\Database.T4.csproj", "{CB50129B-A890-4DF9-9C40-CD6354076A3C}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database.Actions", "Database.Actions\Database.Actions.csproj", "{CEFF114C-1102-43F5-9CD3-3352F18D67A4}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@ Global
 		{2A5D0EC8-E487-4B43-A311-05852464ED01}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2A5D0EC8-E487-4B43-A311-05852464ED01}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{2A5D0EC8-E487-4B43-A311-05852464ED01}.Release|Any CPU.Build.0 = Release|Any CPU
-		{CB50129B-A890-4DF9-9C40-CD6354076A3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{CB50129B-A890-4DF9-9C40-CD6354076A3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{CB50129B-A890-4DF9-9C40-CD6354076A3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{CB50129B-A890-4DF9-9C40-CD6354076A3C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CEFF114C-1102-43F5-9CD3-3352F18D67A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CEFF114C-1102-43F5-9CD3-3352F18D67A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CEFF114C-1102-43F5-9CD3-3352F18D67A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CEFF114C-1102-43F5-9CD3-3352F18D67A4}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/src/Database/App.config b/src/Database/App.config
deleted file mode 100644
index 7a04aeac7dc23cbfd709fcce639c8fd7a1a20ae1..0000000000000000000000000000000000000000
--- a/src/Database/App.config
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-  <configSections>
-        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
-        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
-    </configSections>
-  <runtime>
-    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-      <dependentAssembly>
-        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
-      </dependentAssembly>
-      <dependentAssembly>
-        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
-      </dependentAssembly>
-    </assemblyBinding>
-  </runtime>
-  <entityFramework>
-    <providers>
-      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
-    </providers>
-  </entityFramework>
-</configuration>
\ No newline at end of file
diff --git a/src/Database/CoscineDB.cs b/src/Database/CoscineDB.cs
new file mode 100644
index 0000000000000000000000000000000000000000..4cf3c170cf37328e5923e7eab8b83106e2c8a012
--- /dev/null
+++ b/src/Database/CoscineDB.cs
@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore;
+using Coscine.Database.Settings;
+using Coscine.Database.DataModel;
+using Coscine.Configuration;
+
+
+namespace Coscine.Database
+{
+    public partial class CoscineDB : Model
+    {
+        public static DatabaseSettingsConfiguration DatabaseSettingsConfiguration { get; set; }
+
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+        {
+            DatabaseSettingsConfiguration databaseSettingsConfiguration;
+            if (DatabaseSettingsConfiguration == null)
+            {
+                IConfiguration _configuration = new ConsulConfiguration();
+                databaseSettingsConfiguration = new DatabaseSettingsConfiguration(_configuration);
+            } 
+            else
+            {
+                databaseSettingsConfiguration = DatabaseSettingsConfiguration;
+            }
+            optionsBuilder.UseSqlServer(databaseSettingsConfiguration.ConnectionStrings());
+        }
+    }
+}
diff --git a/src/Database/CustomDesignTimeService.cs b/src/Database/CustomDesignTimeService.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1bd05650b496aa3f716531fc80761551429c6ec0
--- /dev/null
+++ b/src/Database/CustomDesignTimeService.cs
@@ -0,0 +1,26 @@
+using Microsoft.EntityFrameworkCore.Design;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Coscine.Database
+{
+    public class CustomDesignTimeService : IDesignTimeServices
+    {
+        public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
+                    => serviceCollection.AddSingleton<IPluralizer, CustomPluralizer>();
+    }
+    
+    public class CustomPluralizer : IPluralizer
+    {
+        Inflector.Inflector _inflector = new Inflector.Inflector(System.Globalization.CultureInfo.GetCultureInfo("en-us"));
+
+        public string Pluralize(string identifier)
+        {
+            return _inflector.Pluralize(identifier) ?? identifier;
+        }
+
+        public string Singularize(string identifier)
+        {
+            return _inflector.Singularize(identifier) ?? identifier;
+        }
+    }
+}
diff --git a/src/Database/DataModel/ActivatedFeature.cs b/src/Database/DataModel/ActivatedFeature.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1c7552b69874f3c73f0adf7fe29b450572ba89fc
--- /dev/null
+++ b/src/Database/DataModel/ActivatedFeature.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ActivatedFeature
+    {
+        public Guid Id { get; set; }
+        public Guid ProjectId { get; set; }
+        public Guid FeatureId { get; set; }
+
+        public virtual Feature Feature { get; set; }
+        public virtual Project Project { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ApiToken.cs b/src/Database/DataModel/ApiToken.cs
new file mode 100644
index 0000000000000000000000000000000000000000..132c0bec8eb35a96f07c732f20c901328727fe0d
--- /dev/null
+++ b/src/Database/DataModel/ApiToken.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ApiToken
+    {
+        public Guid Id { get; set; }
+        public string Name { get; set; }
+        public Guid UserId { get; set; }
+        public DateTime IssuedAt { get; set; }
+        public DateTime Expiration { get; set; }
+
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ContactChange.cs b/src/Database/DataModel/ContactChange.cs
new file mode 100644
index 0000000000000000000000000000000000000000..abed9b1417ba07f9a723fc34598b653fed0ae0f5
--- /dev/null
+++ b/src/Database/DataModel/ContactChange.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ContactChange
+    {
+        public Guid RelationId { get; set; }
+        public Guid UserId { get; set; }
+        public string NewEmail { get; set; }
+        public DateTime? EditDate { get; set; }
+        public Guid ConfirmationToken { get; set; }
+
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Discipline.cs b/src/Database/DataModel/Discipline.cs
new file mode 100644
index 0000000000000000000000000000000000000000..48ac8705c1178eea8d7dbb5b8b8a52e729dcc459
--- /dev/null
+++ b/src/Database/DataModel/Discipline.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Discipline
+    {
+        public Discipline()
+        {
+            ProjectDisciplines = new HashSet<ProjectDiscipline>();
+            ResourceDisciplines = new HashSet<ResourceDiscipline>();
+            UserDisciplines = new HashSet<UserDiscipline>();
+        }
+
+        public Guid Id { get; set; }
+        public string Url { get; set; }
+        public string DisplayNameDe { get; set; }
+        public string DisplayNameEn { get; set; }
+
+        public virtual ICollection<ProjectDiscipline> ProjectDisciplines { get; set; }
+        public virtual ICollection<ResourceDiscipline> ResourceDisciplines { get; set; }
+        public virtual ICollection<UserDiscipline> UserDisciplines { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ExternalAuthenticator.cs b/src/Database/DataModel/ExternalAuthenticator.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6a3ec8f12bf6980d504091c37c311a6cce885b10
--- /dev/null
+++ b/src/Database/DataModel/ExternalAuthenticator.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ExternalAuthenticator
+    {
+        public ExternalAuthenticator()
+        {
+            ExternalIds = new HashSet<ExternalId>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+
+        public virtual ICollection<ExternalId> ExternalIds { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ExternalId.cs b/src/Database/DataModel/ExternalId.cs
new file mode 100644
index 0000000000000000000000000000000000000000..35b36d328621e25ee843d1f7f1e41aed4be575ea
--- /dev/null
+++ b/src/Database/DataModel/ExternalId.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ExternalId
+    {
+        public Guid RelationId { get; set; }
+        public Guid UserId { get; set; }
+        public Guid ExternalAuthenticatorId { get; set; }
+        public string ExternalId1 { get; set; }
+        public string Organization { get; set; }
+
+        public virtual ExternalAuthenticator ExternalAuthenticator { get; set; }
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Feature.cs b/src/Database/DataModel/Feature.cs
new file mode 100644
index 0000000000000000000000000000000000000000..15797b25aa060e0992ec8e6edc1b438f776b7aba
--- /dev/null
+++ b/src/Database/DataModel/Feature.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Feature
+    {
+        public Feature()
+        {
+            ActivatedFeatures = new HashSet<ActivatedFeature>();
+        }
+
+        public Guid Id { get; set; }
+        public string SharepointId { get; set; }
+        public string DisplaynameEn { get; set; }
+        public string DisplaynameDe { get; set; }
+
+        public virtual ICollection<ActivatedFeature> ActivatedFeatures { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/GitlabResourceType.cs b/src/Database/DataModel/GitlabResourceType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..3291a9b9b420794e08c70e1fe81c5150894f8d33
--- /dev/null
+++ b/src/Database/DataModel/GitlabResourceType.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class GitlabResourceType
+    {
+        public Guid Id { get; set; }
+        public int RepositoryNumber { get; set; }
+        public string RepositoryUrl { get; set; }
+        public string Token { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Group.cs b/src/Database/DataModel/Group.cs
new file mode 100644
index 0000000000000000000000000000000000000000..5089a11a5f10248de71237ba48ffe61c0c69b228
--- /dev/null
+++ b/src/Database/DataModel/Group.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Group
+    {
+        public Group()
+        {
+            GroupMemberships = new HashSet<GroupMembership>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+
+        public virtual ICollection<GroupMembership> GroupMemberships { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/GroupMembership.cs b/src/Database/DataModel/GroupMembership.cs
new file mode 100644
index 0000000000000000000000000000000000000000..40e310ca0a046250b8a3fbcc585483a676d7cce5
--- /dev/null
+++ b/src/Database/DataModel/GroupMembership.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class GroupMembership
+    {
+        public Guid RelationId { get; set; }
+        public Guid GroupId { get; set; }
+        public Guid UserId { get; set; }
+
+        public virtual Group Group { get; set; }
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Kpi.cs b/src/Database/DataModel/Kpi.cs
new file mode 100644
index 0000000000000000000000000000000000000000..bfa004e411522ca060a35509126bf36bb84b7e2c
--- /dev/null
+++ b/src/Database/DataModel/Kpi.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Kpi
+    {
+        public Guid Id { get; set; }
+        public string MeasurementId { get; set; }
+        public string Ikz { get; set; }
+        public double? Value { get; set; }
+        public DateTime? Start { get; set; }
+        public DateTime? End { get; set; }
+        public string AdditionalInfo { get; set; }
+        public string AdditionalInfo1 { get; set; }
+        public string AdditionalInfo2 { get; set; }
+        public string AdditionalInfo3 { get; set; }
+        public string AdditionalInfo4 { get; set; }
+        public string AdditionalInfo5 { get; set; }
+        public bool SentSuccessfully { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Language.cs b/src/Database/DataModel/Language.cs
new file mode 100644
index 0000000000000000000000000000000000000000..c0bd2ccaa9170e6f1f85aaa030ac2fae7ed4b9bd
--- /dev/null
+++ b/src/Database/DataModel/Language.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Language
+    {
+        public Language()
+        {
+            Users = new HashSet<User>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+        public string Abbreviation { get; set; }
+
+        public virtual ICollection<User> Users { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/License.cs b/src/Database/DataModel/License.cs
new file mode 100644
index 0000000000000000000000000000000000000000..52eb539f216a221dcb0b85506729e366589880ac
--- /dev/null
+++ b/src/Database/DataModel/License.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class License
+    {
+        public License()
+        {
+            Resources = new HashSet<Resource>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+
+        public virtual ICollection<Resource> Resources { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/LinkedResourceType.cs b/src/Database/DataModel/LinkedResourceType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1b07722c893c205fea35aa4f1b59f3c7dd2fc214
--- /dev/null
+++ b/src/Database/DataModel/LinkedResourceType.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class LinkedResourceType
+    {
+        public Guid Id { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Log.cs b/src/Database/DataModel/Log.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1d4432d07fb822d684d914c3085312550d11b62b
--- /dev/null
+++ b/src/Database/DataModel/Log.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Log
+    {
+        public Guid Id { get; set; }
+        public DateTime? ServerTimestamp { get; set; }
+        public DateTime? ClientTimestamp { get; set; }
+        public string LogLevel { get; set; }
+        public string Message { get; set; }
+        public string Stacktrace { get; set; }
+        public Guid? UserId { get; set; }
+        public string Uri { get; set; }
+        public string Server { get; set; }
+        public Guid? CorrolationId { get; set; }
+        public string Status { get; set; }
+        public string Source { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Model.cs b/src/Database/DataModel/Model.cs
new file mode 100644
index 0000000000000000000000000000000000000000..4745489d36ef647cdef333f627cfe95d8d776538
--- /dev/null
+++ b/src/Database/DataModel/Model.cs
@@ -0,0 +1,687 @@
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Model : DbContext
+    {
+        public Model()
+        {
+        }
+
+        public Model(DbContextOptions<Model> options)
+            : base(options)
+        {
+        }
+
+        public virtual DbSet<ActivatedFeature> ActivatedFeatures { get; set; }
+        public virtual DbSet<ApiToken> ApiTokens { get; set; }
+        public virtual DbSet<Discipline> Disciplines { get; set; }
+        public virtual DbSet<ExternalAuthenticator> ExternalAuthenticators { get; set; }
+        public virtual DbSet<ExternalId> ExternalIds { get; set; }
+        public virtual DbSet<Feature> Features { get; set; }
+        public virtual DbSet<GitlabResourceType> GitlabResourceTypes { get; set; }
+        public virtual DbSet<Group> Groups { get; set; }
+        public virtual DbSet<GroupMembership> GroupMemberships { get; set; }
+        public virtual DbSet<Kpi> Kpis { get; set; }
+        public virtual DbSet<Language> Languages { get; set; }
+        public virtual DbSet<License> Licenses { get; set; }
+        public virtual DbSet<LinkedResourceType> LinkedResourceTypes { get; set; }
+        public virtual DbSet<Log> Logs { get; set; }
+        public virtual DbSet<Project> Projects { get; set; }
+        public virtual DbSet<ProjectDiscipline> ProjectDisciplines { get; set; }
+        public virtual DbSet<ProjectInstitute> ProjectInstitutes { get; set; }
+        public virtual DbSet<ProjectQuota> ProjectQuotas { get; set; }
+        public virtual DbSet<ProjectResource> ProjectResources { get; set; }
+        public virtual DbSet<ProjectRole> ProjectRoles { get; set; }
+        public virtual DbSet<RdsresourceType> RdsresourceTypes { get; set; }
+        public virtual DbSet<Resource> Resources { get; set; }
+        public virtual DbSet<ResourceDiscipline> ResourceDisciplines { get; set; }
+        public virtual DbSet<ResourceType> ResourceTypes { get; set; }
+        public virtual DbSet<Role> Roles { get; set; }
+        public virtual DbSet<S3resourceType> S3resourceTypes { get; set; }
+        public virtual DbSet<SubProject> SubProjects { get; set; }
+        public virtual DbSet<Title> Titles { get; set; }
+        public virtual DbSet<Tosaccepted> Tosaccepteds { get; set; }
+        public virtual DbSet<User> Users { get; set; }
+        public virtual DbSet<UserDiscipline> UserDisciplines { get; set; }
+        public virtual DbSet<VersionInfo> VersionInfos { get; set; }
+        public virtual DbSet<Visibility> Visibilities { get; set; }
+
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+        {
+            if (!optionsBuilder.IsConfigured)
+            {
+            }
+        }
+
+        protected override void OnModelCreating(ModelBuilder modelBuilder)
+        {
+            modelBuilder.Entity<ActivatedFeature>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Feature)
+                    .WithMany(p => p.ActivatedFeatures)
+                    .HasForeignKey(d => d.FeatureId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ActivatedFeatures_FeatureId_Features_Id");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ActivatedFeatures)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ActivatedFeatures_ProjectId_Projects_Id");
+            });
+
+            modelBuilder.Entity<ApiToken>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Expiration).HasColumnType("datetime");
+
+                entity.Property(e => e.IssuedAt).HasColumnType("datetime");
+
+                entity.Property(e => e.Name)
+                    .IsRequired()
+                    .HasMaxLength(255);
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.ApiTokens)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ApiTokens_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<Discipline>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayNameDe).HasMaxLength(200);
+
+                entity.Property(e => e.DisplayNameEn).HasMaxLength(200);
+
+                entity.Property(e => e.Url)
+                    .IsRequired()
+                    .HasMaxLength(200);
+            });
+
+            modelBuilder.Entity<ExternalAuthenticator>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            modelBuilder.Entity<ExternalId>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.ExternalId1)
+                    .IsRequired()
+                    .HasColumnName("ExternalId")
+                    .HasMaxLength(255);
+
+                entity.Property(e => e.Organization).HasMaxLength(255);
+
+                entity.HasOne(d => d.ExternalAuthenticator)
+                    .WithMany(p => p.ExternalIds)
+                    .HasForeignKey(d => d.ExternalAuthenticatorId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ExternalIds_ResourceTypeId_ExternalAuthenticators_Id");
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.ExternalIds)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ExternalIds_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<Feature>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplaynameDe)
+                    .IsRequired()
+                    .HasMaxLength(200);
+
+                entity.Property(e => e.DisplaynameEn)
+                    .IsRequired()
+                    .HasMaxLength(200);
+
+                entity.Property(e => e.SharepointId)
+                    .IsRequired()
+                    .HasMaxLength(200);
+            });
+
+            modelBuilder.Entity<GitlabResourceType>(entity =>
+            {
+                entity.ToTable("GitlabResourceType");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.RepositoryUrl)
+                    .IsRequired()
+                    .HasMaxLength(500);
+
+                entity.Property(e => e.Token)
+                    .IsRequired()
+                    .HasMaxLength(100);
+            });
+
+            modelBuilder.Entity<Group>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(255);
+            });
+
+            modelBuilder.Entity<GroupMembership>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Group)
+                    .WithMany(p => p.GroupMemberships)
+                    .HasForeignKey(d => d.GroupId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_GroupMemberships_GroupId_Groups_Id");
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.GroupMemberships)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_GroupMemberships_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<Kpi>(entity =>
+            {
+                entity.ToTable("Kpi");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.AdditionalInfo)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.AdditionalInfo1)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.AdditionalInfo2)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.AdditionalInfo3)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.AdditionalInfo4)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.AdditionalInfo5)
+                    .HasMaxLength(500)
+                    .HasDefaultValueSql("(N'')");
+
+                entity.Property(e => e.End)
+                    .HasColumnType("datetime")
+                    .HasDefaultValueSql("(getdate())");
+
+                entity.Property(e => e.Ikz).HasMaxLength(9);
+
+                entity.Property(e => e.MeasurementId)
+                    .HasColumnName("MeasurementID")
+                    .HasMaxLength(500);
+
+                entity.Property(e => e.Start)
+                    .HasColumnType("datetime")
+                    .HasDefaultValueSql("(getdate())");
+            });
+
+            modelBuilder.Entity<Language>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Abbreviation)
+                    .IsRequired()
+                    .HasMaxLength(50);
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            modelBuilder.Entity<License>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            modelBuilder.Entity<LinkedResourceType>(entity =>
+            {
+                entity.ToTable("LinkedResourceType");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+            });
+
+            modelBuilder.Entity<Log>(entity =>
+            {
+                entity.ToTable("Log");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.ClientTimestamp)
+                    .HasColumnType("datetime")
+                    .HasDefaultValueSql("(getdate())");
+
+                entity.Property(e => e.LogLevel).HasMaxLength(20);
+
+                entity.Property(e => e.Server).HasMaxLength(200);
+
+                entity.Property(e => e.ServerTimestamp)
+                    .HasColumnType("datetime")
+                    .HasDefaultValueSql("(getdate())");
+
+                entity.Property(e => e.Source).HasMaxLength(200);
+
+                entity.Property(e => e.Status).HasMaxLength(200);
+
+                entity.Property(e => e.Uri)
+                    .HasColumnName("URI")
+                    .HasMaxLength(500);
+            });
+
+            modelBuilder.Entity<Project>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Description).IsRequired();
+
+                entity.Property(e => e.DisplayName).HasMaxLength(25);
+
+                entity.Property(e => e.EndDate).HasColumnType("datetime");
+
+                entity.Property(e => e.GrantId).HasMaxLength(500);
+
+                entity.Property(e => e.Keywords).HasMaxLength(1000);
+
+                entity.Property(e => e.PrincipleInvestigators).HasMaxLength(500);
+
+                entity.Property(e => e.ProjectName)
+                    .IsRequired()
+                    .HasMaxLength(200);
+
+                entity.Property(e => e.Slug)
+                    .IsRequired()
+                    .HasMaxLength(63);
+
+                entity.Property(e => e.StartDate)
+                    .HasColumnType("datetime")
+                    .HasDefaultValueSql("(getdate())");
+
+                entity.HasOne(d => d.Visibility)
+                    .WithMany(p => p.Projects)
+                    .HasForeignKey(d => d.VisibilityId)
+                    .HasConstraintName("FK_Projects_VisibilityId_Visibilities_Id");
+            });
+
+            modelBuilder.Entity<ProjectDiscipline>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.ToTable("ProjectDiscipline");
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Discipline)
+                    .WithMany(p => p.ProjectDisciplines)
+                    .HasForeignKey(d => d.DisciplineId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectDiscipline_DisciplineId_Disciplines_Id");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ProjectDisciplines)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectDiscipline_ProjectId_Projects_Id");
+            });
+
+            modelBuilder.Entity<ProjectInstitute>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.ToTable("ProjectInstitute");
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.OrganizationUrl)
+                    .IsRequired()
+                    .HasMaxLength(255)
+                    .HasDefaultValueSql("(N'https://www.rwth-aachen.de/22000')");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ProjectInstitutes)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectInstitute_ProjectId_Projects_Id");
+            });
+
+            modelBuilder.Entity<ProjectQuota>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Quota).HasDefaultValueSql("((25))");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ProjectQuotas)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectQuotas_ProjectId_Projects_Id");
+
+                entity.HasOne(d => d.ResourceType)
+                    .WithMany(p => p.ProjectQuotas)
+                    .HasForeignKey(d => d.ResourceTypeId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectQuotas_ResourceTypeId_ResourceTypes_Id");
+            });
+
+            modelBuilder.Entity<ProjectResource>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.ToTable("ProjectResource");
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ProjectResources)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectResource_ProjectId_Projects_Id");
+
+                entity.HasOne(d => d.Resource)
+                    .WithMany(p => p.ProjectResources)
+                    .HasForeignKey(d => d.ResourceId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectResource_ResourceId_Resources_Id");
+            });
+
+            modelBuilder.Entity<ProjectRole>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.ProjectRoles)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectRoles_ProjectId_Projects_Id");
+
+                entity.HasOne(d => d.Role)
+                    .WithMany(p => p.ProjectRoles)
+                    .HasForeignKey(d => d.RoleId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectRoles_RoleId_Roles_Id");
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.ProjectRoles)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ProjectRoles_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<RdsresourceType>(entity =>
+            {
+                entity.ToTable("RDSResourceType");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.BucketName)
+                    .IsRequired()
+                    .HasMaxLength(63);
+            });
+
+            modelBuilder.Entity<Resource>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.ApplicationProfile).HasMaxLength(500);
+
+                entity.Property(e => e.DisplayName).HasMaxLength(25);
+
+                entity.Property(e => e.Keywords).HasMaxLength(1000);
+
+                entity.Property(e => e.ResourceName).HasMaxLength(200);
+
+                entity.Property(e => e.UsageRights).HasMaxLength(200);
+
+                entity.HasOne(d => d.License)
+                    .WithMany(p => p.Resources)
+                    .HasForeignKey(d => d.LicenseId)
+                    .HasConstraintName("FK_Resources_LicenseId_Licenses_Id");
+
+                entity.HasOne(d => d.Type)
+                    .WithMany(p => p.Resources)
+                    .HasForeignKey(d => d.TypeId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_Resources_TypeId_ResourceTypes_Id");
+
+                entity.HasOne(d => d.Visibility)
+                    .WithMany(p => p.Resources)
+                    .HasForeignKey(d => d.VisibilityId)
+                    .HasConstraintName("FK_Resources_VisibilityId_Visibilities_Id");
+            });
+
+            modelBuilder.Entity<ResourceDiscipline>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.ToTable("ResourceDiscipline");
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Discipline)
+                    .WithMany(p => p.ResourceDisciplines)
+                    .HasForeignKey(d => d.DisciplineId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ResourceDiscipline_DisciplineId_Disciplines_Id");
+
+                entity.HasOne(d => d.Resource)
+                    .WithMany(p => p.ResourceDisciplines)
+                    .HasForeignKey(d => d.ResourceId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_ResourceDiscipline_ResourceId_Resources_Id");
+            });
+
+            modelBuilder.Entity<ResourceType>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+
+                entity.Property(e => e.Enabled)
+                    .IsRequired()
+                    .HasDefaultValueSql("((1))");
+            });
+
+            modelBuilder.Entity<Role>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Description)
+                    .IsRequired()
+                    .HasMaxLength(50);
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            modelBuilder.Entity<S3resourceType>(entity =>
+            {
+                entity.ToTable("S3ResourceType");
+
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.AccessKey).HasMaxLength(200);
+
+                entity.Property(e => e.BucketName)
+                    .IsRequired()
+                    .HasMaxLength(63);
+
+                entity.Property(e => e.ResourceUrl)
+                    .IsRequired()
+                    .HasMaxLength(200);
+
+                entity.Property(e => e.SecretKey).HasMaxLength(200);
+            });
+
+            modelBuilder.Entity<SubProject>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Project)
+                    .WithMany(p => p.SubProjectProjects)
+                    .HasForeignKey(d => d.ProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_SubProjects_ProjectId_Projects_Id");
+
+                entity.HasOne(d => d.SubProjectNavigation)
+                    .WithMany(p => p.SubProjectSubProjectNavigations)
+                    .HasForeignKey(d => d.SubProjectId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_SubProjects_SubProjectId_Projects_Id");
+            });
+
+            modelBuilder.Entity<Title>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            modelBuilder.Entity<Tosaccepted>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.ToTable("TOSAccepted");
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.Version)
+                    .IsRequired()
+                    .HasMaxLength(10);
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.Tosaccepteds)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_TOSAccepted_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<User>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(255);
+
+                entity.Property(e => e.EmailAddress).HasMaxLength(200);
+
+                entity.Property(e => e.Entitlement).HasMaxLength(200);
+
+                entity.Property(e => e.Givenname).HasMaxLength(200);
+
+                entity.Property(e => e.Institute).HasMaxLength(200);
+
+                entity.Property(e => e.Organization).HasMaxLength(200);
+
+                entity.Property(e => e.Surname).HasMaxLength(200);
+
+                entity.HasOne(d => d.Language)
+                    .WithMany(p => p.Users)
+                    .HasForeignKey(d => d.LanguageId)
+                    .HasConstraintName("FK_Users_LanguageId_Languages_Id");
+
+                entity.HasOne(d => d.Title)
+                    .WithMany(p => p.Users)
+                    .HasForeignKey(d => d.TitleId)
+                    .HasConstraintName("FK_Users_TitleId_Titles_Id");
+            });
+
+            modelBuilder.Entity<UserDiscipline>(entity =>
+            {
+                entity.HasKey(e => e.RelationId);
+
+                entity.Property(e => e.RelationId).HasDefaultValueSql("(newid())");
+
+                entity.HasOne(d => d.Discipline)
+                    .WithMany(p => p.UserDisciplines)
+                    .HasForeignKey(d => d.DisciplineId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_UserDisciplines_DisciplineId_Disciplines_Id");
+
+                entity.HasOne(d => d.User)
+                    .WithMany(p => p.UserDisciplines)
+                    .HasForeignKey(d => d.UserId)
+                    .OnDelete(DeleteBehavior.ClientSetNull)
+                    .HasConstraintName("FK_UserDisciplines_UserId_Users_Id");
+            });
+
+            modelBuilder.Entity<VersionInfo>(entity =>
+            {
+                entity.HasNoKey();
+
+                entity.ToTable("VersionInfo");
+
+                entity.HasIndex(e => e.Version)
+                    .HasName("UC_Version")
+                    .IsUnique()
+                    .IsClustered();
+
+                entity.Property(e => e.AppliedOn).HasColumnType("datetime");
+
+                entity.Property(e => e.Description).HasMaxLength(1024);
+            });
+
+            modelBuilder.Entity<Visibility>(entity =>
+            {
+                entity.Property(e => e.Id).HasDefaultValueSql("(newid())");
+
+                entity.Property(e => e.DisplayName)
+                    .IsRequired()
+                    .HasMaxLength(50);
+            });
+
+            OnModelCreatingPartial(modelBuilder);
+        }
+
+        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+    }
+}
diff --git a/src/Database/DataModel/Project.cs b/src/Database/DataModel/Project.cs
new file mode 100644
index 0000000000000000000000000000000000000000..8d425ff0fefca7eeb3842393ad2191c70c62bcaf
--- /dev/null
+++ b/src/Database/DataModel/Project.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Project
+    {
+        public Project()
+        {
+            ActivatedFeatures = new HashSet<ActivatedFeature>();
+            ProjectDisciplines = new HashSet<ProjectDiscipline>();
+            ProjectInstitutes = new HashSet<ProjectInstitute>();
+            ProjectQuotas = new HashSet<ProjectQuota>();
+            ProjectResources = new HashSet<ProjectResource>();
+            ProjectRoles = new HashSet<ProjectRole>();
+            SubProjectProjects = new HashSet<SubProject>();
+            SubProjectSubProjectNavigations = new HashSet<SubProject>();
+        }
+
+        public Guid Id { get; set; }
+        public string ProjectName { get; set; }
+        public string Description { get; set; }
+        public DateTime StartDate { get; set; }
+        public DateTime EndDate { get; set; }
+        public string Keywords { get; set; }
+        public string DisplayName { get; set; }
+        public string PrincipleInvestigators { get; set; }
+        public string GrantId { get; set; }
+        public Guid? VisibilityId { get; set; }
+        public bool Deleted { get; set; }
+        public string Slug { get; set; }
+
+        public virtual Visibility Visibility { get; set; }
+        public virtual ICollection<ActivatedFeature> ActivatedFeatures { get; set; }
+        public virtual ICollection<ProjectDiscipline> ProjectDisciplines { get; set; }
+        public virtual ICollection<ProjectInstitute> ProjectInstitutes { get; set; }
+        public virtual ICollection<ProjectQuota> ProjectQuotas { get; set; }
+        public virtual ICollection<ProjectResource> ProjectResources { get; set; }
+        public virtual ICollection<ProjectRole> ProjectRoles { get; set; }
+        public virtual ICollection<SubProject> SubProjectProjects { get; set; }
+        public virtual ICollection<SubProject> SubProjectSubProjectNavigations { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ProjectDiscipline.cs b/src/Database/DataModel/ProjectDiscipline.cs
new file mode 100644
index 0000000000000000000000000000000000000000..31ebc39f2efe03ee044dbefa43e41315e1ac9daf
--- /dev/null
+++ b/src/Database/DataModel/ProjectDiscipline.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ProjectDiscipline
+    {
+        public Guid RelationId { get; set; }
+        public Guid DisciplineId { get; set; }
+        public Guid ProjectId { get; set; }
+
+        public virtual Discipline Discipline { get; set; }
+        public virtual Project Project { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ProjectInstitute.cs b/src/Database/DataModel/ProjectInstitute.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2562b230dba1fad4b7d22bca2c4cf4612fe3ab2c
--- /dev/null
+++ b/src/Database/DataModel/ProjectInstitute.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ProjectInstitute
+    {
+        public Guid RelationId { get; set; }
+        public Guid ProjectId { get; set; }
+        public string OrganizationUrl { get; set; }
+
+        public virtual Project Project { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ProjectQuota.cs b/src/Database/DataModel/ProjectQuota.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d6b4d48789aceaaec78629ef2207d18ca6b52330
--- /dev/null
+++ b/src/Database/DataModel/ProjectQuota.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ProjectQuota
+    {
+        public Guid RelationId { get; set; }
+        public Guid ProjectId { get; set; }
+        public Guid ResourceTypeId { get; set; }
+        public int Quota { get; set; }
+
+        public virtual Project Project { get; set; }
+        public virtual ResourceType ResourceType { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ProjectResource.cs b/src/Database/DataModel/ProjectResource.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d66f35c122d6a97c606b3902c27639a0a1e6c086
--- /dev/null
+++ b/src/Database/DataModel/ProjectResource.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ProjectResource
+    {
+        public Guid RelationId { get; set; }
+        public Guid ResourceId { get; set; }
+        public Guid ProjectId { get; set; }
+
+        public virtual Project Project { get; set; }
+        public virtual Resource Resource { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ProjectRole.cs b/src/Database/DataModel/ProjectRole.cs
new file mode 100644
index 0000000000000000000000000000000000000000..daccbd261b35b3c740f542ebd4a1570824437785
--- /dev/null
+++ b/src/Database/DataModel/ProjectRole.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ProjectRole
+    {
+        public Guid RelationId { get; set; }
+        public Guid ProjectId { get; set; }
+        public Guid UserId { get; set; }
+        public Guid RoleId { get; set; }
+
+        public virtual Project Project { get; set; }
+        public virtual Role Role { get; set; }
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/RdsresourceType.cs b/src/Database/DataModel/RdsresourceType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..88751a2511be2d79e44568ff24ccff70c924cf18
--- /dev/null
+++ b/src/Database/DataModel/RdsresourceType.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class RdsresourceType
+    {
+        public Guid Id { get; set; }
+        public string BucketName { get; set; }
+        public int? Size { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Resource.cs b/src/Database/DataModel/Resource.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6ed78bc6bcb494b8c1943b986a5f299d8a5f1fc2
--- /dev/null
+++ b/src/Database/DataModel/Resource.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Resource
+    {
+        public Resource()
+        {
+            ProjectResources = new HashSet<ProjectResource>();
+            ResourceDisciplines = new HashSet<ResourceDiscipline>();
+        }
+
+        public Guid Id { get; set; }
+        public Guid TypeId { get; set; }
+        public string ResourceName { get; set; }
+        public string DisplayName { get; set; }
+        public Guid? VisibilityId { get; set; }
+        public Guid? LicenseId { get; set; }
+        public string Keywords { get; set; }
+        public string UsageRights { get; set; }
+        public Guid? ResourceTypeOptionId { get; set; }
+        public string Description { get; set; }
+        public string ApplicationProfile { get; set; }
+        public string FixedValues { get; set; }
+        public Guid? Creator { get; set; }
+
+        public virtual License License { get; set; }
+        public virtual ResourceType Type { get; set; }
+        public virtual Visibility Visibility { get; set; }
+        public virtual ICollection<ProjectResource> ProjectResources { get; set; }
+        public virtual ICollection<ResourceDiscipline> ResourceDisciplines { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ResourceDiscipline.cs b/src/Database/DataModel/ResourceDiscipline.cs
new file mode 100644
index 0000000000000000000000000000000000000000..bdf727a9551a7bac7d11897291932d79325835f7
--- /dev/null
+++ b/src/Database/DataModel/ResourceDiscipline.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ResourceDiscipline
+    {
+        public Guid RelationId { get; set; }
+        public Guid DisciplineId { get; set; }
+        public Guid ResourceId { get; set; }
+
+        public virtual Discipline Discipline { get; set; }
+        public virtual Resource Resource { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/ResourceType.cs b/src/Database/DataModel/ResourceType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..822c9bf40e6acd7db80e831a4ecc36388f4bc27d
--- /dev/null
+++ b/src/Database/DataModel/ResourceType.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class ResourceType
+    {
+        public ResourceType()
+        {
+            ProjectQuotas = new HashSet<ProjectQuota>();
+            Resources = new HashSet<Resource>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+        public bool? Enabled { get; set; }
+
+        public virtual ICollection<ProjectQuota> ProjectQuotas { get; set; }
+        public virtual ICollection<Resource> Resources { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Role.cs b/src/Database/DataModel/Role.cs
new file mode 100644
index 0000000000000000000000000000000000000000..35aa3a4ac3a5e2aed12d5bc2bd6bea8f766f2cde
--- /dev/null
+++ b/src/Database/DataModel/Role.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Role
+    {
+        public Role()
+        {
+            ProjectRoles = new HashSet<ProjectRole>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+        public string Description { get; set; }
+
+        public virtual ICollection<ProjectRole> ProjectRoles { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/S3resourceType.cs b/src/Database/DataModel/S3resourceType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..0547f3b61929f97a6254ac323890316bd3988d2a
--- /dev/null
+++ b/src/Database/DataModel/S3resourceType.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class S3resourceType
+    {
+        public Guid Id { get; set; }
+        public string BucketName { get; set; }
+        public string AccessKey { get; set; }
+        public string SecretKey { get; set; }
+        public string ResourceUrl { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/SubProject.cs b/src/Database/DataModel/SubProject.cs
new file mode 100644
index 0000000000000000000000000000000000000000..bf47edd86680bfd87cf4072d2f0745f3a9cf1e9e
--- /dev/null
+++ b/src/Database/DataModel/SubProject.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class SubProject
+    {
+        public Guid RelationId { get; set; }
+        public Guid ProjectId { get; set; }
+        public Guid SubProjectId { get; set; }
+
+        public virtual Project Project { get; set; }
+        public virtual Project SubProjectNavigation { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Title.cs b/src/Database/DataModel/Title.cs
new file mode 100644
index 0000000000000000000000000000000000000000..b921efaf4baed497648813abe7bc57f932a9888b
--- /dev/null
+++ b/src/Database/DataModel/Title.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Title
+    {
+        public Title()
+        {
+            Users = new HashSet<User>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+
+        public virtual ICollection<User> Users { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Tosaccepted.cs b/src/Database/DataModel/Tosaccepted.cs
new file mode 100644
index 0000000000000000000000000000000000000000..6eefb860cca67e9236190f361b4c1613fa375bc4
--- /dev/null
+++ b/src/Database/DataModel/Tosaccepted.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Tosaccepted
+    {
+        public Guid RelationId { get; set; }
+        public Guid UserId { get; set; }
+        public string Version { get; set; }
+
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/User.cs b/src/Database/DataModel/User.cs
new file mode 100644
index 0000000000000000000000000000000000000000..693b6adb7e504ace2f69e8cc474f81018fdf936a
--- /dev/null
+++ b/src/Database/DataModel/User.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class User
+    {
+        public User()
+        {
+            ApiTokens = new HashSet<ApiToken>();
+            ExternalIds = new HashSet<ExternalId>();
+            GroupMemberships = new HashSet<GroupMembership>();
+            ProjectRoles = new HashSet<ProjectRole>();
+            Tosaccepteds = new HashSet<Tosaccepted>();
+            UserDisciplines = new HashSet<UserDiscipline>();
+        }
+
+        public Guid Id { get; set; }
+        public string EmailAddress { get; set; }
+        public string DisplayName { get; set; }
+        public string Givenname { get; set; }
+        public string Surname { get; set; }
+        public string Entitlement { get; set; }
+        public string Organization { get; set; }
+        public Guid? TitleId { get; set; }
+        public Guid? LanguageId { get; set; }
+        public string Institute { get; set; }
+
+        public virtual Language Language { get; set; }
+        public virtual Title Title { get; set; }
+        public virtual ICollection<ApiToken> ApiTokens { get; set; }
+        public virtual ICollection<ExternalId> ExternalIds { get; set; }
+        public virtual ICollection<GroupMembership> GroupMemberships { get; set; }
+        public virtual ICollection<ProjectRole> ProjectRoles { get; set; }
+        public virtual ICollection<Tosaccepted> Tosaccepteds { get; set; }
+        public virtual ICollection<UserDiscipline> UserDisciplines { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/UserDiscipline.cs b/src/Database/DataModel/UserDiscipline.cs
new file mode 100644
index 0000000000000000000000000000000000000000..c4c7be05317ee015eab396d35581848b8f1c5955
--- /dev/null
+++ b/src/Database/DataModel/UserDiscipline.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class UserDiscipline
+    {
+        public Guid RelationId { get; set; }
+        public Guid DisciplineId { get; set; }
+        public Guid UserId { get; set; }
+
+        public virtual Discipline Discipline { get; set; }
+        public virtual User User { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/VersionInfo.cs b/src/Database/DataModel/VersionInfo.cs
new file mode 100644
index 0000000000000000000000000000000000000000..043ca3ce48528d09b68bc48e08306c080dde545e
--- /dev/null
+++ b/src/Database/DataModel/VersionInfo.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class VersionInfo
+    {
+        public long Version { get; set; }
+        public DateTime? AppliedOn { get; set; }
+        public string Description { get; set; }
+    }
+}
diff --git a/src/Database/DataModel/Visibility.cs b/src/Database/DataModel/Visibility.cs
new file mode 100644
index 0000000000000000000000000000000000000000..8022d3f32a99f218f94523f4f3d91c9c1776e9a4
--- /dev/null
+++ b/src/Database/DataModel/Visibility.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace Coscine.Database.DataModel
+{
+    public partial class Visibility
+    {
+        public Visibility()
+        {
+            Projects = new HashSet<Project>();
+            Resources = new HashSet<Resource>();
+        }
+
+        public Guid Id { get; set; }
+        public string DisplayName { get; set; }
+
+        public virtual ICollection<Project> Projects { get; set; }
+        public virtual ICollection<Resource> Resources { get; set; }
+    }
+}
diff --git a/src/Database/Database.csproj b/src/Database/Database.csproj
index 4cabd595ac9a676c88018d82a8917b907edd8b48..0c1d03a41fc691499f7a8e6b445c75aef2e19a23 100644
--- a/src/Database/Database.csproj
+++ b/src/Database/Database.csproj
@@ -1,305 +1,37 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{A7369EA1-F9AB-49D2-BDB1-C3FACD37BBD0}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Coscine.Database</RootNamespace>
-    <AssemblyName>Coscine.Database</AssemblyName>
-    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <NuGetPackageImportStamp>
-    </NuGetPackageImportStamp>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SignAssembly>true</SignAssembly>
-  </PropertyGroup>
-  <PropertyGroup>
-    <AssemblyOriginatorKeyFile>Coscine.Database.Key.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Consul, Version=1.6.1.1, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
-      <HintPath>..\packages\Consul.1.6.1.1\lib\net461\Consul.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Configuration, Version=1.6.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Configuration.1.6.0\lib\net461\Coscine.Configuration.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Database.Helpers, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Database.Helpers.1.2.0\lib\net461\Coscine.Database.Helpers.dll</HintPath>
-    </Reference>
-    <Reference Include="Coscine.Migrations, Version=1.10.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\Coscine.Migrations.1.10.0\lib\net461\Coscine.Migrations.dll</HintPath>
-    </Reference>
-    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
-    </Reference>
-    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
-      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.3.2.11\lib\net461\FluentMigrator.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Abstractions, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Abstractions.3.2.11\lib\net461\FluentMigrator.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Oracle.3.2.11\lib\net461\FluentMigrator.Extensions.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.Postgres.3.2.11\lib\net461\FluentMigrator.Extensions.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Extensions.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Extensions.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Extensions.SqlServer.3.2.11\lib\net461\FluentMigrator.Extensions.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.3.2.11\lib\net461\FluentMigrator.Runner.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Core, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Core.3.2.11\lib\net461\FluentMigrator.Runner.Core.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Db2, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Db2.3.2.11\lib\net461\FluentMigrator.Runner.Db2.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Firebird, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Firebird.3.2.11\lib\net461\FluentMigrator.Runner.Firebird.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Hana, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Hana.3.2.11\lib\net461\FluentMigrator.Runner.Hana.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Jet, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Jet.3.2.11\lib\net461\FluentMigrator.Runner.Jet.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.MySql, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.MySql.3.2.11\lib\net461\FluentMigrator.Runner.MySql.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Oracle, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Oracle.3.2.11\lib\net461\FluentMigrator.Runner.Oracle.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Postgres, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Postgres.3.2.11\lib\net461\FluentMigrator.Runner.Postgres.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.Redshift, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.Redshift.3.2.11\lib\net461\FluentMigrator.Runner.Redshift.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlAnywhere, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlAnywhere.3.2.11\lib\net461\FluentMigrator.Runner.SqlAnywhere.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SQLite, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SQLite.3.2.11\lib\net461\FluentMigrator.Runner.SQLite.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServer, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServer.3.2.11\lib\net461\FluentMigrator.Runner.SqlServer.dll</HintPath>
-    </Reference>
-    <Reference Include="FluentMigrator.Runner.SqlServerCe, Version=3.2.11.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL">
-      <HintPath>..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\lib\net461\FluentMigrator.Runner.SqlServerCe.dll</HintPath>
-    </Reference>
-    <Reference Include="linq2db, Version=3.1.1.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
-      <HintPath>..\packages\linq2db.3.1.1\lib\net46\linq2db.dll</HintPath>
-    </Reference>
-    <Reference Include="LinqKit, Version=1.1.17.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
-      <HintPath>..\packages\LinqKit.1.1.17\lib\net45\LinqKit.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Data.Sqlite, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Data.Sqlite.Core.5.0.2\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.5.0.1\lib\net461\Microsoft.Extensions.DependencyInjection.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.5.0.0\lib\net461\Microsoft.Extensions.Logging.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Options, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Options.5.0.0\lib\net461\Microsoft.Extensions.Options.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
-      <HintPath>..\packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
-    </Reference>
-    <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
-    </Reference>
-    <Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
-      <HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ComponentModel.DataAnnotations" />
-    <Reference Include="System.Configuration" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Data.SqlClient.4.8.2\lib\net461\System.Data.SqlClient.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
-    </Reference>
-    <Reference Include="System.DirectoryServices" />
-    <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Net.Http.WebRequest" />
-    <Reference Include="System.Numerics" />
-    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
-    </Reference>
-    <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Web" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Models\ActivatedFeaturesModel.cs" />
-    <Compile Include="Models\ExternalAuthenticatorModel.cs" />
-    <Compile Include="Models\ExternalIdModel.cs" />
-    <Compile Include="Models\FeaturesModel.cs" />
-    <Compile Include="Models\KpiModel.cs" />
-    <Compile Include="Models\ProjectQuotasModel.cs" />
-    <Compile Include="Models\LinkedResourceTypeModel.cs" />
-    <Compile Include="Models\ApiTokenModel.cs" />
-    <Compile Include="Models\TOSModel.cs" />
-    <Compile Include="ReturnObjects\ActivatedFeatureObject.cs" />
-    <Compile Include="Models\LogModel.cs" />
-    <Compile Include="ReturnObjects\DisciplineObject.cs" />
-    <Compile Include="ReturnObjects\ExternalAuthenticatorsObject.cs" />
-    <Compile Include="ReturnObjects\ExternalIdsObject.cs" />
-    <Compile Include="ReturnObjects\FeatureObject.cs" />
-    <Compile Include="ReturnObjects\GitlabResourceTypeObject.cs" />
-    <Compile Include="ReturnObjects\IReturnObject.cs" />
-    <Compile Include="ReturnObjects\KpiObject.cs" />
-    <Compile Include="ReturnObjects\LanguageObject.cs" />
-    <Compile Include="ReturnObjects\LicenseObject.cs" />
-    <Compile Include="ReturnObjects\OrganizationResourceListObject.cs" />
-    <Compile Include="ReturnObjects\OrganizationCountObject.cs" />
-    <Compile Include="ReturnObjects\OrganizationObject.cs" />
-    <Compile Include="ReturnObjects\ProjectObject.cs" />
-    <Compile Include="ReturnObjects\ProjectQuotaObject.cs" />
-    <Compile Include="ReturnObjects\ProjectRoleObject.cs" />
-    <Compile Include="ReturnObjects\LinkedResourceTypeObject.cs" />
-    <Compile Include="ReturnObjects\RDSResourceTypeObject.cs" />
-    <Compile Include="ReturnObjects\ResourceObject.cs" />
-    <Compile Include="ReturnObjects\ResourceTypeObject.cs" />
-    <Compile Include="ReturnObjects\ResourceTypeOptionObject.cs" />
-    <Compile Include="ReturnObjects\ApiTokenObject.cs" />
-    <Compile Include="ReturnObjects\RoleObject.cs" />
-    <Compile Include="ReturnObjects\S3ResourceTypeObject.cs" />
-    <Compile Include="ReturnObjects\TitleObject.cs" />
-    <Compile Include="ReturnObjects\UserObject.cs" />
-    <Compile Include="ReturnObjects\VisibilityObject.cs" />
-    <Compile Include="ReturnObjects\WaterbutlerFolder.cs" />
-    <Compile Include="Settings\CoscineTestingSettings.cs" />
-    <Compile Include="Util\UserRoles.cs" />
-    <None Include="app.config" />
-    <None Include="Coscine.Database.Key.snk" />
-    <Compile Include="Settings\ConnectionStringSettings.cs" />
-    <Compile Include="Settings\CoscineSettings.cs" />
-    <Compile Include="Util\DatabaseConnection.cs" />
-    <Compile Include="Models\DatabaseModel.cs" />
-    <Compile Include="Models\DisciplineModel.cs" />
-    <Compile Include="Models\GitlabResourceTypeModel.cs" />
-    <Compile Include="Models\LanguageModel.cs" />
-    <Compile Include="Models\LicenseModel.cs" />
-    <Compile Include="Models\MetadataModel.cs" />
-    <Compile Include="Models\ProjectDisciplineModel.cs" />
-    <Compile Include="Models\ProjectInstituteModel.cs" />
-    <Compile Include="Models\ProjectModel.cs" />
-    <Compile Include="Models\ProjectResourceModel.cs" />
-    <Compile Include="Models\ProjectRoleModel.cs" />
-    <Compile Include="Models\RDSResourceTypeModel.cs" />
-    <Compile Include="Models\ResourceDisciplineModel.cs" />
-    <Compile Include="Models\ResourceModel.cs" />
-    <Compile Include="Models\ResourceTypeModel.cs" />
-    <Compile Include="Models\RoleModel.cs" />
-    <Compile Include="Models\S3ResourceTypeModel.cs" />
-    <Compile Include="Models\SubProjectModel.cs" />
-    <Compile Include="Models\TitleModel.cs" />
-    <Compile Include="Models\UserModel.cs" />
-    <Compile Include="Models\UserDisciplineModel.cs" />
-    <Compile Include="Models\VisibilityModel.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Database.T4\Database.T4.csproj">
-      <Project>{cb50129b-a890-4df9-9c40-cd6354076a3c}</Project>
-      <Name>Database.T4</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
-    <PropertyGroup>
-      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
-    </PropertyGroup>
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
-    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
-    <Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
-    <Error Condition="!Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets'))" />
-  </Target>
-  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
-  <Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
-  <Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.2.11\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
-</Project>
\ No newline at end of file
+<Project Sdk="Microsoft.NET.Sdk">
+	<PropertyGroup>
+		<OutputType>Library</OutputType>
+		<RootNamespace>Coscine.Database</RootNamespace>
+		<AssemblyName>Coscine.Database</AssemblyName>
+		<TargetFrameworks>net5.0;net461</TargetFrameworks>
+		<Version>1.28.0</Version>
+	</PropertyGroup>
+	<PropertyGroup>
+		<Authors>RWTH Aachen University</Authors>
+		<Company>IT Center, RWTH Aachen University</Company>
+		<Copyright>2021 IT Center, RWTH Aachen University</Copyright>
+		<Description>Database is a part of the Coscine group.</Description>
+		<PackageLicenseExpression>MIT</PackageLicenseExpression>
+		<PackageProjectUrl>https://git.rwth-aachen.de/coscine/backend/libraries/database</PackageProjectUrl>
+		<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
+	</PropertyGroup>
+	<PropertyGroup>
+		<SignAssembly>true</SignAssembly>
+		<AssemblyOriginatorKeyFile>Coscine.Database.Key.snk</AssemblyOriginatorKeyFile>
+	</PropertyGroup>
+	<ItemGroup>
+		<None Include="Coscine.Database.Key.snk" />
+		<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461'" />
+	</ItemGroup>
+	<ItemGroup>
+		<PackageReference Include="Coscine.Configuration" Version="2.*-*" />
+		<PackageReference Include="LinqKit" Version="1.1.23" />
+		<PackageReference Include="Inflector.NetStandard" Version="1.2.2" />
+		<!-- Note: use Microsoft.EntityFrameworkCore Version 3.x.x for compatibility with net461 -->
+		<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.12" PrivateAssets="all" />
+		<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.12" />
+	</ItemGroup>
+	<PropertyGroup>
+		<LangVersion>Preview</LangVersion>
+	</PropertyGroup>
+</Project>
diff --git a/src/Database/Database.nuspec b/src/Database/Database.nuspec
deleted file mode 100644
index 492c94f31274d55e5a50f0b898797d2c0e0194d7..0000000000000000000000000000000000000000
--- a/src/Database/Database.nuspec
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<package >
-  <metadata>
-    <id>$id$</id>
-    <version>$version$</version>
-    <title>$title$</title>
-    <authors>rwth-aachen</authors>
-    <owners>rwth-aachen</owners>
-    <license type="expression">MIT</license>
-    <projectUrl>https://git.rwth-aachen.de/coscine/cs/database</projectUrl>
-    <requireLicenseAcceptance>false</requireLicenseAcceptance>
-    <description>$description$</description>
-    <copyright>$copyright$</copyright>
-  </metadata>
-  <files>
-	<file src="bin\Release\Coscine.Database.T4.dll" target="lib\net461" />
-  </files>
-</package>
\ No newline at end of file
diff --git a/src/Database/Models/ActivatedFeaturesModel.cs b/src/Database/Models/ActivatedFeaturesModel.cs
index 50aca2ef4b1fe55312c9fc57baaab96ded961bd8..9066ee4e312f4307da3ebe67a80294f76e7fd724 100644
--- a/src/Database/Models/ActivatedFeaturesModel.cs
+++ b/src/Database/Models/ActivatedFeaturesModel.cs
@@ -1,6 +1,6 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.Util;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -15,7 +15,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<ActivatedFeature> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<ActivatedFeature> GetITableFromDatabase(CoscineDB db)
         {
             return db.ActivatedFeatures;
         }
diff --git a/src/Database/Models/ApiTokenModel.cs b/src/Database/Models/ApiTokenModel.cs
index 241a3e5d47a6742645dbdabd8b527f5bda89b83a..539f35452bc9cb4d69ac7c41f74f8062ec7c2d2e 100644
--- a/src/Database/Models/ApiTokenModel.cs
+++ b/src/Database/Models/ApiTokenModel.cs
@@ -1,6 +1,6 @@
 using Coscine.Database.DataModel;
+using Microsoft.EntityFrameworkCore;
 using Coscine.Database.ReturnObjects;
-using LinqToDB;
 using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
@@ -15,7 +15,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<ApiToken> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<ApiToken> GetITableFromDatabase(CoscineDB db)
         {
             return db.ApiTokens;
         }
diff --git a/src/Database/Models/DatabaseModel.cs b/src/Database/Models/DatabaseModel.cs
index ad1c79a60aeb296596c1077b8bbb6f778c1ca116..1f9b7f272aa3e1286195cedb7f98e472c88266d0 100644
--- a/src/Database/Models/DatabaseModel.cs
+++ b/src/Database/Models/DatabaseModel.cs
@@ -1,21 +1,21 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.Util;
-using LinqKit;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
+using LinqKit;
 
 namespace Coscine.Database.Models
 {
-    public abstract class DatabaseModel<T>
+    public abstract class DatabaseModel<T> where T : class
     {
         public abstract Expression<Func<T, Guid>> GetIdFromObject();
 
         public abstract void SetObjectId(T databaseObject, Guid id);
 
-        public abstract ITable<T> GetITableFromDatabase(CoscineDB db);
+        public abstract Microsoft.EntityFrameworkCore.DbSet<T> GetITableFromDatabase(CoscineDB db);
 
 
         // GetById utilizes the Expression functionality since Linq2Sql does not support method calls
@@ -68,13 +68,13 @@ namespace Coscine.Database.Models
         {
             return DatabaseConnection.ConnectToDatabase((db) =>
             {
-                return db.Update(databaseObject);
+                return (int) db.Update(databaseObject).State;
             });
         }
 
         public virtual int Insert(T databaseObject)
         {
-            if (GetIdFromObject().Invoke(databaseObject) == new Guid("00000000-0000-0000-0000-000000000000"))
+            if (GetIdFromObject().Compile()(databaseObject) == new Guid("00000000-0000-0000-0000-000000000000"))
             {
                 SetObjectId(databaseObject, Guid.NewGuid());
             }
diff --git a/src/Database/Models/DisciplineModel.cs b/src/Database/Models/DisciplineModel.cs
index fc149ac8587890b82d0e9fac95c2b5d272609c7a..e5c588c40fad270a5e0b279d24a04215fa928d2a 100644
--- a/src/Database/Models/DisciplineModel.cs
+++ b/src/Database/Models/DisciplineModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (discipline) => discipline.Id;
         }
 
-        public override ITable<Discipline> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<Discipline> GetITableFromDatabase(CoscineDB db)
         {
             return db.Disciplines;
         }
diff --git a/src/Database/Models/ExternalAuthenticatorModel.cs b/src/Database/Models/ExternalAuthenticatorModel.cs
index 956b3f977e108236354ced8c5de9b78d4c31ce5b..517cb295491f72f0b1549f1a3053a21e6e810d75 100644
--- a/src/Database/Models/ExternalAuthenticatorModel.cs
+++ b/src/Database/Models/ExternalAuthenticatorModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (value) => value.Id;
         }
 
-        public override ITable<ExternalAuthenticator> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<ExternalAuthenticator> GetITableFromDatabase(CoscineDB db)
         {
             return db.ExternalAuthenticators;
         }
diff --git a/src/Database/Models/ExternalIdModel.cs b/src/Database/Models/ExternalIdModel.cs
index 01aea2b05f8e4701fd97a29b89c57069aa8bea40..0d7df01a8f005939db5261361b07611204428341 100644
--- a/src/Database/Models/ExternalIdModel.cs
+++ b/src/Database/Models/ExternalIdModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (value) => value.RelationId;
         }
 
-        public override ITable<ExternalId> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<ExternalId> GetITableFromDatabase(CoscineDB db)
         {
             return db.ExternalIds;
         }
diff --git a/src/Database/Models/FeaturesModel.cs b/src/Database/Models/FeaturesModel.cs
index 83485ef9cbace034c66d420b948e49ef0d6f4fcf..806497da441bc382ec9479212de378e9be108183 100644
--- a/src/Database/Models/FeaturesModel.cs
+++ b/src/Database/Models/FeaturesModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<Feature> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<Feature> GetITableFromDatabase(CoscineDB db)
         {
             return db.Features;
         }
diff --git a/src/Database/Models/GitlabResourceTypeModel.cs b/src/Database/Models/GitlabResourceTypeModel.cs
index d88b07636512c6b26a3082eed8108e29adcfd2ad..1e2e7798c49cdcdb81c822310c9307946ebec84d 100644
--- a/src/Database/Models/GitlabResourceTypeModel.cs
+++ b/src/Database/Models/GitlabResourceTypeModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
@@ -13,7 +13,7 @@ namespace Coscine.Database.Models
             return (gitlabResourceType) => gitlabResourceType.Id;
         }
 
-        public override ITable<GitlabResourceType> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<GitlabResourceType> GetITableFromDatabase(CoscineDB db)
         {
             return db.GitlabResourceTypes;
         }
diff --git a/src/Database/Models/KpiModel.cs b/src/Database/Models/KpiModel.cs
index 402d5e9dc229695d6db531ee4d2415f4d2baa230..0d1bd8ae6e319002c6bfd4e20200a64ae65088a1 100644
--- a/src/Database/Models/KpiModel.cs
+++ b/src/Database/Models/KpiModel.cs
@@ -1,4 +1,5 @@
 using Coscine.Database.DataModel;
+using Microsoft.EntityFrameworkCore;
 using Coscine.Database.Util;
 using System;
 using System.Collections.Generic;
@@ -15,7 +16,7 @@ namespace Coscine.Database.Models
             return (KpiObject) => KpiObject.Id;
         }
 
-        public override LinqToDB.ITable<Kpi> GetITableFromDatabase(CoscineDB db)
+        public override DbSet<Kpi> GetITableFromDatabase(CoscineDB db)
         {
             return db.Kpis;
         }
diff --git a/src/Database/Models/LanguageModel.cs b/src/Database/Models/LanguageModel.cs
index ab7b4dd9d4bccc0082afe8978e1811e504952a0f..f03c82367dc40eb800618bc84ec8962fc9f809a5 100644
--- a/src/Database/Models/LanguageModel.cs
+++ b/src/Database/Models/LanguageModel.cs
@@ -10,7 +10,7 @@ namespace Coscine.Database.Models
             return (language) => language.Id;
         }
 
-        public override LinqToDB.ITable<Language> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Language> GetITableFromDatabase(CoscineDB db)
         {
             return db.Languages;
         }
diff --git a/src/Database/Models/LicenseModel.cs b/src/Database/Models/LicenseModel.cs
index 87866edd1fde3c66974ae8e6f4278773ac025e9e..86e07bfb84231854d2cd92f89c3143f0c4806b69 100644
--- a/src/Database/Models/LicenseModel.cs
+++ b/src/Database/Models/LicenseModel.cs
@@ -10,7 +10,7 @@ namespace Coscine.Database.Models
             return (license) => license.Id;
         }
 
-        public override LinqToDB.ITable<License> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<License> GetITableFromDatabase(CoscineDB db)
         {
             return db.Licenses;
         }
diff --git a/src/Database/Models/LinkedResourceTypeModel.cs b/src/Database/Models/LinkedResourceTypeModel.cs
index 2df1349d7ccc3577f3b48d5c2691367be00d65bc..5722efcc3ac84c5e7148d863e9ea8868dfd0e6c2 100644
--- a/src/Database/Models/LinkedResourceTypeModel.cs
+++ b/src/Database/Models/LinkedResourceTypeModel.cs
@@ -1,5 +1,4 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
 using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
@@ -13,7 +12,7 @@ namespace Coscine.Database.Models
             return (linkedResourceType) => linkedResourceType.Id;
         }
 
-        public override ITable<LinkedResourceType> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<LinkedResourceType> GetITableFromDatabase(CoscineDB db)
         {
             return db.LinkedResourceTypes;
         }
diff --git a/src/Database/Models/LogModel.cs b/src/Database/Models/LogModel.cs
index 9edc8cb5734b9701385d0200acd860f3f3a191d2..d1bb63a3819cd01ba6af55f183875e413f7f629e 100644
--- a/src/Database/Models/LogModel.cs
+++ b/src/Database/Models/LogModel.cs
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return log => log.Id;
         }
 
-        public override LinqToDB.ITable<Log> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Log> GetITableFromDatabase(CoscineDB db)
         {
             return db.Logs;
         }
diff --git a/src/Database/Models/MetadataModel.cs b/src/Database/Models/MetadataModel.cs
index bd8b6b75dca31dfa6e2ee194827d158a503fa603..76d854e843c4617341eac7a9d2746292dc5a8520 100644
--- a/src/Database/Models/MetadataModel.cs
+++ b/src/Database/Models/MetadataModel.cs
@@ -1,6 +1,5 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
-using LinqToDB;
 using System;
 using System.Linq.Expressions;
 using System.Web;
@@ -20,7 +19,7 @@ namespace Coscine.Database.Models
             throw new NotImplementedException();
         }
 
-        public override ITable<Resource> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Resource> GetITableFromDatabase(CoscineDB db)
         {
             throw new NotImplementedException();
         }
diff --git a/src/Database/Models/ProjectDisciplineModel.cs b/src/Database/Models/ProjectDisciplineModel.cs
index 19ffb210c718fb1c4ab1e7d65d9f777874ab2b3f..462d934933f78e089f7fbe15e2b4c76b83bcbccd 100644
--- a/src/Database/Models/ProjectDisciplineModel.cs
+++ b/src/Database/Models/ProjectDisciplineModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (projectDiscipline) => projectDiscipline.RelationId;
         }
 
-        public override ITable<ProjectDiscipline> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ProjectDiscipline> GetITableFromDatabase(CoscineDB db)
         {
             return db.ProjectDisciplines;
         }
diff --git a/src/Database/Models/ProjectInstituteModel.cs b/src/Database/Models/ProjectInstituteModel.cs
index 176b4a8fe7e54cec3a5808dd462e80b4615be969..9791fe4a83900405d968fee3eb4b65a6f346ddc9 100644
--- a/src/Database/Models/ProjectInstituteModel.cs
+++ b/src/Database/Models/ProjectInstituteModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (projectInstitute) => projectInstitute.RelationId;
         }
 
-        public override ITable<ProjectInstitute> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ProjectInstitute> GetITableFromDatabase(CoscineDB db)
         {
             return db.ProjectInstitutes;
         }
diff --git a/src/Database/Models/ProjectModel.cs b/src/Database/Models/ProjectModel.cs
index 4c6982f80f076a4587f8219d4290e9e46496fa5b..9e58f60e09906d830c052e857ff7be4f45365272 100644
--- a/src/Database/Models/ProjectModel.cs
+++ b/src/Database/Models/ProjectModel.cs
@@ -1,14 +1,15 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
 using Coscine.Database.Util;
-using LinqKit;
-using LinqToDB;
+
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Text.RegularExpressions;
 
+using LinqKit;
+
 namespace Coscine.Database.Models
 {
     public class ProjectModel : DatabaseModel<Project>
@@ -18,7 +19,7 @@ namespace Coscine.Database.Models
             return DatabaseConnection.ConnectToDatabase((db) =>
             {
                 return
-                    (from tableEntry in GetITableFromDatabase(db).AsExpandable()
+                    (from tableEntry in GetITableFromDatabase(db)
                      where tableEntry.Id == id
                             && tableEntry.Deleted == true
                      select tableEntry).Count() == 1;
@@ -96,7 +97,7 @@ namespace Coscine.Database.Models
             {
                 return DatabaseConnection.ConnectToDatabase((db) =>
                 {
-                    return db.Update(databaseObject);
+                    return (int) db.Update(databaseObject).State;
                 });
             }
             else
@@ -110,7 +111,7 @@ namespace Coscine.Database.Models
             databaseObject.Deleted = true;
             return DatabaseConnection.ConnectToDatabase((db) =>
             {
-                return db.Update(databaseObject);
+                return (int) db.Update(databaseObject).State;
             });
         }
 
@@ -327,9 +328,9 @@ namespace Coscine.Database.Models
         public IEnumerable<Project> GetTopLevelWithAccess(User user, params string[] allowedAccess)
         {
             return GetWithAccess(user, allowedAccess, (allowedProjectIds) => GetAllWhere((project) => allowedProjectIds.Contains(project.Id) &&
-                    ((!project.SubProjectsSubProjectIdIds.Any()) // get top level projects not having any parent projects
-                        || !(from subProject in project.SubProjectsSubProjectIdIds // check if the direct parent project is accessible to the current user
-                             where (from parentProjectRole in subProject.Project.ProjectRolesProjectIdIds
+                    ((!project.SubProjectProjects.Any()) // get top level projects not having any parent projects
+                        || !(from subProject in project.SubProjectProjects // check if the direct parent project is accessible to the current user
+                             where (from parentProjectRole in subProject.Project.ProjectRoles
                                     where parentProjectRole.UserId == user.Id
                                     && allowedAccess.Contains(parentProjectRole.Role.DisplayName.ToLower())
                                     select parentProjectRole).Any()
@@ -382,29 +383,15 @@ namespace Coscine.Database.Models
 
         public ProjectObject CreateReturnObjectFromDatabaseObject(Project project, Guid parentId)
         {
-            IEnumerable<DisciplineObject> disciplines = new List<DisciplineObject>();
-            if (project.ProjectDisciplineProjectIdIds == null)
-            {
-                DisciplineModel disciplineModel = new DisciplineModel();
-                disciplines = disciplineModel.GetAllWhere((discipline) => (from relation in discipline.ProjectDisciplineDisciplineIdIds where relation.ProjectId == project.Id select relation).Any())
+            IEnumerable<DisciplineObject> disciplines = new List<DisciplineObject>();            
+            DisciplineModel disciplineModel = new DisciplineModel();
+            disciplines = disciplineModel.GetAllWhere((discipline) => (from relation in discipline.ProjectDisciplines where relation.ProjectId == project.Id select relation).Any())
                                                 .Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
-            }
-            else
-            {
-                disciplines = project.ProjectDisciplineProjectIdIds.Select((discipline) => new DisciplineObject(discipline.Discipline.Id, discipline.Discipline.Url, discipline.Discipline.DisplayNameDe, discipline.Discipline.DisplayNameEn));
-            }
 
             IEnumerable<OrganizationObject> organizations = new List<OrganizationObject>();
-            if (project.ProjectInstituteProjectIdIds == null)
-            {
                 ProjectInstituteModel projectInstituteModel = new ProjectInstituteModel();
                 organizations = projectInstituteModel.GetAllWhere((projectInstitute) => (projectInstitute.ProjectId == project.Id))
                                                 .Select((projectInstitute) => new OrganizationObject(projectInstitute.OrganizationUrl, projectInstitute.OrganizationUrl));
-            }
-            else
-            {
-                organizations = project.ProjectInstituteProjectIdIds.Select((institute) => new OrganizationObject(institute.OrganizationUrl, institute.OrganizationUrl));
-            }
 
             if (project.Visibility == null && project.VisibilityId.HasValue)
             {
@@ -435,7 +422,7 @@ namespace Coscine.Database.Models
             bool continueLoop = true;
             do
             {
-                list = GetAllWhere((dbProject) => (from subProject in dbProject.SubProjectsProjectIdIds
+                list = GetAllWhere((dbProject) => (from subProject in dbProject.SubProjectProjects
                                                    where subProject.SubProjectId == currentProject.Id
                                                    && subProject.Project.Deleted == false
                                                    select subProject).Any());
@@ -473,7 +460,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<Project> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Project> GetITableFromDatabase(CoscineDB db)
         {
             return db.Projects;
         }
diff --git a/src/Database/Models/ProjectQuotasModel.cs b/src/Database/Models/ProjectQuotasModel.cs
index 1ebf3742947e1f7ea35c4d5f2555b4b5176d16e1..7780462076e8ef1e8b50821c8473757255f989e9 100644
--- a/src/Database/Models/ProjectQuotasModel.cs
+++ b/src/Database/Models/ProjectQuotasModel.cs
@@ -1,6 +1,6 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -32,7 +32,7 @@ namespace Coscine.Database.Models
             return (projectQuota) => projectQuota.RelationId;
         }
 
-        public override ITable<ProjectQuota> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ProjectQuota> GetITableFromDatabase(CoscineDB db)
         {
             return db.ProjectQuotas;
         }
diff --git a/src/Database/Models/ProjectResourceModel.cs b/src/Database/Models/ProjectResourceModel.cs
index 179555bab4520aa615a850cda3ddc481661489db..37d059b7d4b73bf603155c421814deb47f693185 100644
--- a/src/Database/Models/ProjectResourceModel.cs
+++ b/src/Database/Models/ProjectResourceModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq;
 using System.Linq.Expressions;
@@ -13,7 +13,7 @@ namespace Coscine.Database.Models
             return (projectResource) => projectResource.RelationId;
         }
 
-        public override ITable<ProjectResource> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ProjectResource> GetITableFromDatabase(CoscineDB db)
         {
             return db.ProjectResources;
         }
diff --git a/src/Database/Models/ProjectRoleModel.cs b/src/Database/Models/ProjectRoleModel.cs
index a5e4e41f86c86d7a7b0c522fe3ad6b1c726f6f85..7b660a9dbaa6d1c32ec62487a9f3fac1f3f6d7f3 100644
--- a/src/Database/Models/ProjectRoleModel.cs
+++ b/src/Database/Models/ProjectRoleModel.cs
@@ -1,6 +1,6 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
-using LinqToDB;
+
 using System;
 using System.Linq;
 using System.Linq.Expressions;
@@ -55,7 +55,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.RelationId;
         }
 
-        public override ITable<ProjectRole> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ProjectRole> GetITableFromDatabase(CoscineDB db)
         {
             return db.ProjectRoles;
         }
diff --git a/src/Database/Models/RDSResourceTypeModel.cs b/src/Database/Models/RDSResourceTypeModel.cs
index b79c2a930e66bd8c55dbe036f646eb8d947ab2db..59af1d31989c3e3a34ef3df6d83d1b99613d10db 100644
--- a/src/Database/Models/RDSResourceTypeModel.cs
+++ b/src/Database/Models/RDSResourceTypeModel.cs
@@ -1,24 +1,24 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
 
 namespace Coscine.Database.Models
 {
-    public class RDSResourceTypeModel : DatabaseModel<RDSResourceType>
+    public class RDSResourceTypeModel : DatabaseModel<RdsresourceType>
     {
-        public override Expression<Func<RDSResourceType, Guid>> GetIdFromObject()
+        public override Expression<Func<RdsresourceType, Guid>> GetIdFromObject()
         {
             return (rdsResourceType) => rdsResourceType.Id;
         }
 
-        public override ITable<RDSResourceType> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<RdsresourceType> GetITableFromDatabase(CoscineDB db)
         {
-            return db.RDSResourceTypes;
+            return db.RdsresourceTypes;
         }
 
-        public override void SetObjectId(RDSResourceType databaseObject, Guid id)
+        public override void SetObjectId(RdsresourceType databaseObject, Guid id)
         {
             databaseObject.Id = id;
         }
diff --git a/src/Database/Models/ResourceDisciplineModel.cs b/src/Database/Models/ResourceDisciplineModel.cs
index c31c45b939496f667fe9934d53f64b44a9b60373..2043beaacb52e7c6db4a74513027e4d5d7baf2a4 100644
--- a/src/Database/Models/ResourceDisciplineModel.cs
+++ b/src/Database/Models/ResourceDisciplineModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (resourceDiscipline) => resourceDiscipline.RelationId;
         }
 
-        public override ITable<ResourceDiscipline> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ResourceDiscipline> GetITableFromDatabase(CoscineDB db)
         {
             return db.ResourceDisciplines;
         }
diff --git a/src/Database/Models/ResourceModel.cs b/src/Database/Models/ResourceModel.cs
index 7020cf0aa887ba38944fb1b4a1fbf3289493dd5c..c3abd508dbff0d7b4e33ca2a656d565f462152a6 100644
--- a/src/Database/Models/ResourceModel.cs
+++ b/src/Database/Models/ResourceModel.cs
@@ -1,7 +1,7 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
 using Coscine.Database.Util;
-using LinqToDB;
+
 using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
@@ -14,7 +14,7 @@ namespace Coscine.Database.Models
     {
         public Resource StoreFromObject(ResourceObject resourceObject)
         {
-            if (resourceObject.Disciplines.Count() == 0 || resourceObject.ResourceTypeOption == null)
+            if (!resourceObject.Disciplines.Any() || resourceObject.ResourceTypeOption == null)
             {
                 throw new ArgumentException("Discipline and ResourceTypeOption are necessary!");
             }
@@ -27,7 +27,6 @@ namespace Coscine.Database.Models
                 Keywords = resourceObject.Keywords,
                 UsageRights = resourceObject.UsageRights,
                 TypeId = resourceObject.Type.Id,
-                Type = new ResourceTypeModel().GetById(resourceObject.Type.Id),
                 VisibilityId = resourceObject.Visibility.Id,
                 ApplicationProfile = resourceObject.ApplicationProfile,
                 FixedValues = resourceObject.FixedValues != null ? resourceObject.FixedValues.ToString() : "{}",
@@ -39,6 +38,7 @@ namespace Coscine.Database.Models
             }
             Insert(resource);
 
+            resource.Type = new ResourceTypeModel().GetById(resourceObject.Type.Id);
             try
             {
                 SetDisciplines(resource, resourceObject.Disciplines);
@@ -112,12 +112,12 @@ namespace Coscine.Database.Models
                 RDSResourceTypeModel rdsResourceTypeModel = new RDSResourceTypeModel();
                 if (resource.ResourceTypeOptionId != null)
                 {
-                    RDSResourceType rdsResourceType = rdsResourceTypeModel.GetById(resource.ResourceTypeOptionId.Value);
+                    RdsresourceType rdsResourceType = rdsResourceTypeModel.GetById(resource.ResourceTypeOptionId.Value);
                     rdsResourceTypeModel.Update(rdsResourceType);
                 }
                 else
                 {
-                    RDSResourceType rdsResourceType = new RDSResourceType()
+                    RdsresourceType rdsResourceType = new RdsresourceType()
                     {
                         BucketName = resource.Id.ToString(),
                         Size = rdsResourceTypeObject.Size,
@@ -133,7 +133,7 @@ namespace Coscine.Database.Models
                 S3ResourceTypeModel s3ResourceTypeModel = new S3ResourceTypeModel();
                 if (resource.ResourceTypeOptionId != null)
                 {
-                    S3ResourceType s3ResourceType = s3ResourceTypeModel.GetById(resource.ResourceTypeOptionId.Value);
+                    S3resourceType s3ResourceType = s3ResourceTypeModel.GetById(resource.ResourceTypeOptionId.Value);
 
                     s3ResourceType.BucketName = s3ResourceTypeObject.BucketName;
                     s3ResourceType.AccessKey = s3ResourceTypeObject.AccessKey ?? s3ResourceType.AccessKey;
@@ -143,7 +143,7 @@ namespace Coscine.Database.Models
                 }
                 else
                 {
-                    S3ResourceType s3ResourceType = new S3ResourceType()
+                    S3resourceType s3ResourceType = new S3resourceType()
                     {
                         BucketName = s3ResourceTypeObject.BucketName,
                         AccessKey = s3ResourceTypeObject.AccessKey,
@@ -329,7 +329,7 @@ namespace Coscine.Database.Models
 
             DisciplineModel disciplineModel = new DisciplineModel();
             var disciplines = disciplineModel.GetAllWhere((discipline) =>
-                            (from relation in discipline.ResourceDisciplineDisciplineIdIds
+                            (from relation in discipline.ResourceDisciplines//ResourceDisciplineDisciplineIdIds
                              where relation.ResourceId == resource.Id
                              select relation).Any())
                             .Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
@@ -395,7 +395,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<Resource> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Resource> GetITableFromDatabase(CoscineDB db)
         {
             return db.Resources;
         }
diff --git a/src/Database/Models/ResourceTypeModel.cs b/src/Database/Models/ResourceTypeModel.cs
index 87149e65a08aedc6c902164c6f7862f35851f09f..87a5b0a4ba7f6291f7bfbbe11ae53673279203cf 100644
--- a/src/Database/Models/ResourceTypeModel.cs
+++ b/src/Database/Models/ResourceTypeModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<ResourceType> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<ResourceType> GetITableFromDatabase(CoscineDB db)
         {
             return db.ResourceTypes;
         }
diff --git a/src/Database/Models/RoleModel.cs b/src/Database/Models/RoleModel.cs
index 365c1873908ac1126db346ba3483a296f93403fb..7538342bd9cbd11e3d8b98df2cb556fc48c734ff 100644
--- a/src/Database/Models/RoleModel.cs
+++ b/src/Database/Models/RoleModel.cs
@@ -1,6 +1,6 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.Util;
-using LinqToDB;
+
 using System;
 using System.Linq;
 using System.Linq.Expressions;
@@ -14,7 +14,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<Role> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Role> GetITableFromDatabase(CoscineDB db)
         {
             return db.Roles;
         }
diff --git a/src/Database/Models/S3ResourceTypeModel.cs b/src/Database/Models/S3ResourceTypeModel.cs
index 60cd394128eece8719e939c26efecaf7a15c9a5d..57f231b97fae3f87735f8aefa626e7e2b02c58dc 100644
--- a/src/Database/Models/S3ResourceTypeModel.cs
+++ b/src/Database/Models/S3ResourceTypeModel.cs
@@ -1,24 +1,24 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
 
 namespace Coscine.Database.Models
 {
-    public class S3ResourceTypeModel : DatabaseModel<S3ResourceType>
+    public class S3ResourceTypeModel : DatabaseModel<S3resourceType>
     {
-        public override Expression<Func<S3ResourceType, Guid>> GetIdFromObject()
+        public override Expression<Func<S3resourceType, Guid>> GetIdFromObject()
         {
             return (rdsResourceType) => rdsResourceType.Id;
         }
 
-        public override ITable<S3ResourceType> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<S3resourceType> GetITableFromDatabase(CoscineDB db)
         {
-            return db.S3ResourceTypes;
+            return db.S3resourceTypes;
         }
 
-        public override void SetObjectId(S3ResourceType databaseObject, Guid id)
+        public override void SetObjectId(S3resourceType databaseObject, Guid id)
         {
             databaseObject.Id = id;
         }
diff --git a/src/Database/Models/SubProjectModel.cs b/src/Database/Models/SubProjectModel.cs
index e178c00cc74f488b5359646ba65e21b3f905627e..f0863dea63ad992469430b0c5d775b8a80af74e2 100644
--- a/src/Database/Models/SubProjectModel.cs
+++ b/src/Database/Models/SubProjectModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.RelationId;
         }
 
-        public override ITable<SubProject> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<SubProject> GetITableFromDatabase(CoscineDB db)
         {
             return db.SubProjects;
         }
diff --git a/src/Database/Models/TOSModel.cs b/src/Database/Models/TOSModel.cs
index e085abdcee471aa5d83c910859a3a42cea8265c7..25a4c4cdec767c0d1cc5bfa901f8b991bcf308c4 100644
--- a/src/Database/Models/TOSModel.cs
+++ b/src/Database/Models/TOSModel.cs
@@ -1,23 +1,22 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
 using System;
 using System.Linq.Expressions;
 
 namespace Coscine.Database.Models
 {
-    public class TOSModel : DatabaseModel<TOSAccepted>
+    public class TOSModel : DatabaseModel<Tosaccepted>
     {
-        public override Expression<Func<TOSAccepted, Guid>> GetIdFromObject()
+        public override Expression<Func<Tosaccepted, Guid>> GetIdFromObject()
         {
             return (tosAccepted) => tosAccepted.RelationId;
         }
 
-        public override ITable<TOSAccepted> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Tosaccepted> GetITableFromDatabase(CoscineDB db)
         {
-            return db.TOSAccepteds;
+            return db.Tosaccepteds;
         }
 
-        public override void SetObjectId(TOSAccepted databaseObject, Guid id)
+        public override void SetObjectId(Tosaccepted databaseObject, Guid id)
         {
             databaseObject.RelationId = id;
         }
diff --git a/src/Database/Models/TitleModel.cs b/src/Database/Models/TitleModel.cs
index 43d29bac367027e7315f1ef9a51d3217e118d8a2..36f1c817f4af4f0c916906b6036752035efd6b2c 100644
--- a/src/Database/Models/TitleModel.cs
+++ b/src/Database/Models/TitleModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (title) => title.Id;
         }
 
-        public override ITable<Title> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Title> GetITableFromDatabase(CoscineDB db)
         {
             return db.Titles;
         }
diff --git a/src/Database/Models/UserDisciplineModel.cs b/src/Database/Models/UserDisciplineModel.cs
index b60a995ca9cc87e790ccde397084bc4f277c33d0..a6e45215c8042688f6cca00d67db6b06ff8bded5 100644
--- a/src/Database/Models/UserDisciplineModel.cs
+++ b/src/Database/Models/UserDisciplineModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (userDiscipline) => userDiscipline.RelationId;
         }
 
-        public override ITable<UserDiscipline> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<UserDiscipline> GetITableFromDatabase(CoscineDB db)
         {
             return db.UserDisciplines;
         }
diff --git a/src/Database/Models/UserModel.cs b/src/Database/Models/UserModel.cs
index eb6cfd846b56da74d20d1ec630483ddefa62c3dd..799fe4201d78f273830af4efdf4692d9b5e864ee 100644
--- a/src/Database/Models/UserModel.cs
+++ b/src/Database/Models/UserModel.cs
@@ -1,7 +1,7 @@
 using Coscine.Database.DataModel;
 using Coscine.Database.ReturnObjects;
 using Coscine.Database.Util;
-using LinqToDB;
+
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -16,7 +16,7 @@ namespace Coscine.Database.Models
             return databaseObject => databaseObject.Id;
         }
 
-        public override ITable<User> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<User> GetITableFromDatabase(CoscineDB db)
         {
             return db.Users;
         }
@@ -29,21 +29,14 @@ namespace Coscine.Database.Models
         public UserObject CreateReturnObjectFromDatabaseObject(User user)
         {
             IEnumerable<DisciplineObject> disciplines = new List<DisciplineObject>();
-            if (user.UserDisciplinesUserIdIds == null)
-            {
-                DisciplineModel disciplineModel = new DisciplineModel();
-                disciplines = disciplineModel.GetAllWhere((discipline) => (from relation in discipline.UserDisciplinesDisciplineIdIds where relation.UserId == user.Id select relation).Any())
+            DisciplineModel disciplineModel = new DisciplineModel();
+            disciplines = disciplineModel.GetAllWhere((discipline) => (from relation in discipline.UserDisciplines where relation.UserId == user.Id select relation).Any())
                                                 .Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
-            }
-            else
-            {
-                disciplines = user.UserDisciplinesUserIdIds.Select((discipline) => new DisciplineObject(discipline.Discipline.Id, discipline.Discipline.Url, discipline.Discipline.DisplayNameDe, discipline.Discipline.DisplayNameEn));
-            }
 
             var externalAuthenticatorModel = new ExternalAuthenticatorModel();
             var externalAuthenticators = externalAuthenticatorModel.GetAllWhere(
                 (externalAuthenticator) => 
-                    (from relation in externalAuthenticator.ExternalIdsResourceTypeIdIds
+                    (from relation in externalAuthenticator.ExternalIds
                         where relation.UserId == user.Id select relation).Any())
                         .Select((externalAuthenticator) => 
                             new ExternalAuthenticatorsObject(
@@ -95,7 +88,7 @@ namespace Coscine.Database.Models
             return DatabaseConnection.ConnectToDatabase((db) =>
             {
                 return (from u in db.Users
-                        join tos in db.TOSAccepteds on u.Id equals tos.UserId
+                        join tos in db.Tosaccepteds on u.Id equals tos.UserId
                         select u.Id).Distinct().ToList();
             });
         }
diff --git a/src/Database/Models/VisibilityModel.cs b/src/Database/Models/VisibilityModel.cs
index c3f0db92fad39cf02a6530027139da3a888e92fc..5a40e63653f04526c10e0b5b5344a1f591988c93 100644
--- a/src/Database/Models/VisibilityModel.cs
+++ b/src/Database/Models/VisibilityModel.cs
@@ -1,5 +1,5 @@
 using Coscine.Database.DataModel;
-using LinqToDB;
+
 using System;
 using System.Linq.Expressions;
 
@@ -12,7 +12,7 @@ namespace Coscine.Database.Models
             return (visibility) => visibility.Id;
         }
 
-        public override ITable<Visibility> GetITableFromDatabase(CoscineDB db)
+        public override Microsoft.EntityFrameworkCore.DbSet<Visibility> GetITableFromDatabase(CoscineDB db)
         {
             return db.Visibilities;
         }
diff --git a/src/Database/Properties/AssemblyInfo.cs b/src/Database/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8e5b7dec9869a1891a4b29e6a6e623d6dd4a1889..0000000000000000000000000000000000000000
--- a/src/Database/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by Cake.
-// </auto-generated>
-//------------------------------------------------------------------------------
-using System.Reflection;
-
-[assembly: AssemblyTitle("Database")]
-[assembly: AssemblyDescription("Database is a part of the CoScInE group.")]
-[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
-[assembly: AssemblyProduct("Database")]
-[assembly: AssemblyVersion("1.27.0")]
-[assembly: AssemblyFileVersion("1.27.0")]
-[assembly: AssemblyInformationalVersion("1.27.0-product-1154-res0002")]
-[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
-
diff --git a/src/Database/Settings/ConnectionStringSettings.cs b/src/Database/Settings/ConnectionStringSettings.cs
deleted file mode 100644
index 2490f3f30501d40fb99d280f6f2a0c06d0b13fac..0000000000000000000000000000000000000000
--- a/src/Database/Settings/ConnectionStringSettings.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using LinqToDB.Configuration;
-
-namespace Coscine.Database.Settings
-{
-    public class ConnectionStringSettings : IConnectionStringSettings
-    {
-        public string ConnectionString { get; set; }
-        public string Name { get; set; }
-        public string ProviderName { get; set; }
-        public bool IsGlobal => false;
-    }
-}
diff --git a/src/Database/Settings/CoscineSettings.cs b/src/Database/Settings/CoscineSettings.cs
deleted file mode 100644
index 95fbf2dcc3135cf9959130f4539e4f93751d02fc..0000000000000000000000000000000000000000
--- a/src/Database/Settings/CoscineSettings.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using Coscine.Configuration;
-using LinqToDB.Configuration;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Coscine.Database.Settings
-{
-    public class CoscineSettings : ILinqToDBSettings
-    {
-
-        public CoscineSettings(IConfiguration configuration)
-        {
-            Configuration = configuration;
-        }
-
-        public string DbDataSourceKey { get; set; } = "coscine/global/db_data_source";
-        public string DbNameKey { get; set; } = "coscine/global/db_name";
-        public string DbUserIdKey { get; set; } = "coscine/global/db_user_id";
-        public string DbPasswordKey { get; set; } = "coscine/global/db_password";
-
-        public IConfiguration Configuration { get; set; }
-
-        public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
-
-        public string DefaultConfiguration => "SqlServer";
-        public string DefaultDataProvider => "SqlServer";
-
-        public IEnumerable<IConnectionStringSettings> ConnectionStrings
-        {
-            get
-            {
-                var dbDataSource = Configuration.GetStringAndWait(DbDataSourceKey);
-                var dbDatabase = Configuration.GetStringAndWait(DbNameKey);
-                var dbUserId = Configuration.GetStringAndWait(DbUserIdKey);
-                var dbPassword = Configuration.GetStringAndWait(DbPasswordKey);
-
-                yield return
-                    new ConnectionStringSettings
-                    {
-                        Name = "Coscine",
-                        ProviderName = "SqlServer",
-                        ConnectionString = $"Data Source={dbDataSource}; Database={dbDatabase}; User Id={dbUserId}; Password={dbPassword};"
-                };
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Database/Settings/CoscineTestingSettings.cs b/src/Database/Settings/CoscineTestingSettings.cs
deleted file mode 100644
index af1eeaf4f147f0e7e6bad447398983a94450c736..0000000000000000000000000000000000000000
--- a/src/Database/Settings/CoscineTestingSettings.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using Coscine.Configuration;
-using LinqToDB.Configuration;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Coscine.Database.Settings
-{
-    public class CoscineTestingSettings : ILinqToDBSettings
-    {
-
-        public string DatabaseName { get; set; }
-
-        public CoscineTestingSettings(IConfiguration configuration)
-        {
-            Configuration = configuration;
-        }
-
-        public CoscineTestingSettings()
-        {
-            Configuration = new ConsulConfiguration();
-        }
-
-        public string DbDataSourceKey { get; set; } = "coscine/global/db_data_source";
-        public string DbUserIdKey { get; set; } = "coscine/global/db_user_id";
-        public string DbPasswordKey { get; set; } = "coscine/global/db_password";
-
-        public IConfiguration Configuration { get; set; }
-
-        public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
-
-        public string DefaultConfiguration => "SqlServer";
-        public string DefaultDataProvider => "SqlServer";
-
-        public IEnumerable<IConnectionStringSettings> ConnectionStrings
-        {
-            get
-            {
-                var dbDataSource = Configuration.GetStringAndWait(DbDataSourceKey);
-                var dbDatabase = DatabaseName;
-                var dbUserId = Configuration.GetStringAndWait(DbUserIdKey);
-                var dbPassword = Configuration.GetStringAndWait(DbPasswordKey);
-
-                yield return
-                    new ConnectionStringSettings
-                    {
-                        Name = "Coscine_Test",
-                        ProviderName = "SqlServer",
-                        ConnectionString = $"Data Source={dbDataSource}; Database={dbDatabase}; User Id={dbUserId}; Password={dbPassword};"
-                };
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Database/Settings/DatabaseSettings.cs b/src/Database/Settings/DatabaseSettings.cs
new file mode 100644
index 0000000000000000000000000000000000000000..90c622d0ea2dee331849b141448933e1b3a50755
--- /dev/null
+++ b/src/Database/Settings/DatabaseSettings.cs
@@ -0,0 +1,29 @@
+namespace Coscine.Database.Settings
+{
+    public class DatabaseSettings
+
+    {
+        public DatabaseSettings()
+        {
+        }
+
+        public DatabaseSettings(string dataSource, string databaseName, string userId, string password)
+        {
+            DataSource = dataSource;
+            DatabaseName = databaseName;
+            UserId = userId;
+            Password = password;
+        }
+
+        public string DataSource { get; set; }
+        public string DatabaseName { get; set; }
+        public string UserId { get; set; }
+        public string Password { get; set; }
+
+
+        public string ConnectionStrings()
+        {
+            return $"Data Source={DataSource};Integrated Security=False;User ID={UserId};Password={Password};Database={DatabaseName}";
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Database/Settings/DatabaseSettingsConfiguration.cs b/src/Database/Settings/DatabaseSettingsConfiguration.cs
new file mode 100644
index 0000000000000000000000000000000000000000..acc95e3fb1e66e2b0cff2ebc00ae15ae58b44da9
--- /dev/null
+++ b/src/Database/Settings/DatabaseSettingsConfiguration.cs
@@ -0,0 +1,28 @@
+using Coscine.Configuration;
+
+namespace Coscine.Database.Settings
+{
+    public class DatabaseSettingsConfiguration : DatabaseSettings
+    {
+        public DatabaseSettingsConfiguration(IConfiguration configuration)
+        {
+            Configuration = configuration;
+            LoadValuesFromConfiguration();
+        }
+
+        public string DbDataSourceKey { get; set; } = "coscine/global/db_data_source";
+        public string DbNameKey { get; set; } = "coscine/global/db_name";
+        public string DbUserIdKey { get; set; } = "coscine/global/db_user_id";
+        public string DbPasswordKey { get; set; } = "coscine/global/db_password";
+
+        public IConfiguration Configuration { get; set; }
+
+        private void LoadValuesFromConfiguration()
+        {
+            DataSource = Configuration.GetStringAndWait(DbDataSourceKey);
+            DatabaseName = Configuration.GetStringAndWait(DbNameKey);
+            UserId = Configuration.GetStringAndWait(DbUserIdKey);
+            Password = Configuration.GetStringAndWait(DbPasswordKey);
+        }
+    }
+}
diff --git a/src/Database/Util/DatabaseConnection.cs b/src/Database/Util/DatabaseConnection.cs
index 9abacdf52ec539a4058e9f2334b3b87346a3dc27..e323adc41bb308e14a38a273be8385076eb05636 100644
--- a/src/Database/Util/DatabaseConnection.cs
+++ b/src/Database/Util/DatabaseConnection.cs
@@ -1,5 +1,6 @@
 using Coscine.Database.DataModel;
 using System;
+using System.Linq;
 
 namespace Coscine.Database.Util
 {
@@ -10,6 +11,7 @@ namespace Coscine.Database.Util
             using (var coscineDB = new CoscineDB())
             {
                 action.Invoke(coscineDB);
+                coscineDB.SaveChanges();
             }
         }
 
@@ -19,6 +21,7 @@ namespace Coscine.Database.Util
             using (var coscineDB = new CoscineDB())
             {
                 result = func.Invoke(coscineDB);
+                coscineDB.SaveChanges();
             }
             return result;
         }
diff --git a/src/Database/Util/Linq2DbMigration.cs b/src/Database/Util/Linq2DbMigration.cs
new file mode 100644
index 0000000000000000000000000000000000000000..bdb3b4997a0a69938e48e210ad36b003700a4198
--- /dev/null
+++ b/src/Database/Util/Linq2DbMigration.cs
@@ -0,0 +1,62 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace Coscine.Database.Settings
+{
+    [Obsolete("Use Dependency injection pattern instead.")]
+    public static class DataConnection
+    {
+        [Obsolete("Use Dependency injection pattern instead.")]
+        public static ILinqToDBSettings DefaultSettings { get; set; }
+    }
+
+    [Obsolete("Leftover from migration. Remove.")]
+    public interface ILinqToDBSettings
+    {
+
+    }
+
+    [Obsolete("Leftover from migration. Remove.")]
+    public interface IDataProviderSettings { }
+
+    [Obsolete("Leftover from migration. Remove.")]
+    public interface IConnectionStringSettings
+    {
+        string ConnectionString { get; set; }
+        bool IsGlobal { get; }
+        string Name { get; set; }
+        string ProviderName { get; set; }
+    }
+}
+
+    namespace Coscine.Database.Util
+{
+    public static class Linq2DbMigration
+    {
+        [Obsolete("Please use DbSet<T>.Add instead.")]
+        public static int Insert<T>(this DbContext db, T t) where T : class
+        {
+            return (int) db.Add(t).State;
+        }
+
+        [Obsolete("Please use DbSet<T>.RemoveRange instead.")]
+        public static int Delete<T>(this DbContext db, IEnumerable<T> t) where T : class
+        {
+            db.RemoveRange(t);
+            return (int) EntityState.Deleted;
+        }
+
+
+        [Obsolete("Please use DbSet<T>.Remove instead.")]
+        public static int Delete<T>(this DbContext db, T t) where T : class
+        {
+            return (int) db.Remove(t).State;
+        }
+    }
+}
diff --git a/src/Database/packages.config b/src/Database/packages.config
deleted file mode 100644
index 127fa64355de7b05ff5285c95b6f4820bd22dce5..0000000000000000000000000000000000000000
--- a/src/Database/packages.config
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="Consul" version="1.6.1.1" targetFramework="net461" />
-  <package id="Coscine.Configuration" version="1.6.0" targetFramework="net461" />
-  <package id="EntityFramework" version="6.4.4" targetFramework="net461" />
-  <package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net461" />
-</packages>
\ No newline at end of file
diff --git a/tools/packages.config b/tools/packages.config
deleted file mode 100644
index 14aef3bf00189e621993b61ccea2e4a203e73b9b..0000000000000000000000000000000000000000
--- a/tools/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-    <package id="Cake" version="0.36.0" />
-</packages>