Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to EF5, .NET 4 + 4.5 versions, plus extras #4

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
36dddc2
Added an optional constructor to the HookEntityMetadata where the con…
visoft Dec 27, 2011
e5e8356
Added FakeItEasy
visoft Dec 27, 2011
d81564b
Added tests for the context being passed in the metadata
visoft Dec 27, 2011
6e38881
Upgraded to EF 4.2
visoft Jul 31, 2012
640c698
Untracked entities no longer are included in validation check to allo…
visoft Jul 31, 2012
2e8dc9d
Added CHANGELOG
visoft Jul 31, 2012
73fbb26
Moved CHANGELOG to the root directory
visoft Jul 31, 2012
6772488
Added the CHANGELOG as a solution item
visoft Aug 1, 2012
c3ea6d5
Upgraded to EF5
Atrejoe Oct 22, 2012
27bdb3b
Added overload taking an existing DbConnection (+corresponding tests)
Atrejoe Nov 21, 2012
5e0bf08
Converted to .Net 4.5
Atrejoe Nov 21, 2012
dee7d96
Added missing Xml documentation
Atrejoe Nov 21, 2012
07e999d
Added ncrunch file to ignorelist
Atrejoe Nov 21, 2012
ba5821a
Fixed broken unit tests.
visoft Apr 11, 2013
301459c
Changed company name
visoft May 20, 2013
cc7242d
Checked in NuSpec file
visoft May 20, 2013
e1e6d7d
Upgraded to EF5, created 4.0 and 4.5 assemblies, bumped version to 1.0.4
visoft May 21, 2013
2603a4f
Merge remote-tracking branch 'visSoft/EFHooks/master'
Atrejoe May 28, 2013
111a838
Simplified NuGet nuspec
Atrejoe May 28, 2013
327e158
Ignore NCrunchSolution cache
Atrejoe May 29, 2013
322edb0
Bugfix > Corrected clause for finding invalid entities
Atrejoe May 29, 2013
27a1e78
Bumped version, updated changelog
Atrejoe May 29, 2013
494a468
Added NuGet deployment batch files to solution items
Atrejoe May 29, 2013
c943d9d
Cleanup of unused references
Atrejoe May 29, 2013
8024f59
Restored description, bumped version
Atrejoe Jun 5, 2013
41f3c21
add current dbcontext in to HookEntityMetadata when invoke hook
Aug 19, 2013
c7e0278
add to solution
Aug 19, 2013
007bfd3
Merge pull request #1 from kirkchen/master
Atrejoe Aug 30, 2013
12bb6b2
Enabled package restore
Atrejoe Aug 30, 2013
3726bfb
Corrected Entity Framework reference to NuGet version
Atrejoe Aug 30, 2013
fb3835e
Upgraded FakeItEasy for both test projects, removing the need for Cas…
Atrejoe Aug 30, 2013
5ebfc96
Package cleanup
Atrejoe Aug 30, 2013
9650e77
Ignored EntityFramework output dlls
Atrejoe Aug 30, 2013
c447e95
Rebuilt release dlls
Atrejoe Aug 30, 2013
aacee7a
Updated versions ad documentation (pushed to NuGet)
Atrejoe Aug 30, 2013
bc073fb
Corrected failing unit test: TimestampPreInsertHook was supposed not …
Atrejoe Sep 6, 2013
b34cc82
Feature: allowed hooks to support multiple EntityStates
Atrejoe Sep 6, 2013
d170a16
Updated documentation
Atrejoe Sep 6, 2013
d69f8aa
Simplified relation between IHook and derived interfaces
Atrejoe Sep 6, 2013
18f3a83
Used centralized constant for version number, bumped version
Atrejoe Sep 6, 2013
d3868aa
Documented changes
Atrejoe Sep 6, 2013
48be7b6
Published latest version
Atrejoe Sep 6, 2013
f536d6a
Upgrade to Entity Framework 6 (which breaks backwards compatibility w…
visoft Oct 22, 2013
5e99aac
Changed RequiresValidation to be virtual and to return false by default
visoft Oct 22, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ build/
*.suo
*.sln.cache
_ReSharper.*/
*.dotCover
*.user
*.vs10x
*.docstates
*.docstates
*.ncrunchsolution
*.nupkg
*.ncrunchproject
NuGet_publish.bat
*.crunchsolution.cache
packages/*/
/lib/net40/EntityFramework.xml
/lib/net40/EntityFramework.dll
/lib/net45/EntityFramework.dll
/lib/net45/EntityFramework.xml
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
136 changes: 136 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);

Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);

return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## 1.0.2.0

* Upgraded Entity Framework to v4.2.0.0

## 1.0.3.0

* Stopped checking validation on Unchanged entities as this prevents stubs from being used (for things like associations)

## 1.0.4.0

* Upgraded Entity Framework to v5.0.0
* New .NET 4.0 and .NET 4.5 assemblies

## 1.0.5.0

* Merged branches of Visoft and Robert Sirre, adding metadata validation upon save (4.5 feature)

## 1.0.5.1

* Bugfix related to metadata validation (causing some PreActionHooks not to to be called)

## 1.0.5.2

* Added feature suggested by kirkchen : https://github.com/Atrejoe/EFHooks/pull/1

## 1.0.5.3

* Also updated 4.5 version

## 1.0.5.4

* Bugfix > Corrected failing unit test
* Feature > Allowed IHook to target multiple Entity States

## 2.0.0.0

* **Breaking Changes**
* Upgraded Entity Framework to v6.0.1 - EF6 changed namespaces (e.g. `System.Data` to `System.Data.Entity`) around. Because of this, v2.0+ won't work with EF5. Please continue to use an earlier version for your EF5 projects.
19 changes: 19 additions & 0 deletions EFHooks.NET45/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
</configuration>
136 changes: 136 additions & 0 deletions EFHooks.NET45/EFHooks.NET45.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{A06C0D39-588B-4F1D-8F4B-A9BAC5930E5C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EFHooks</RootNamespace>
<AssemblyName>EFHooks</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</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>..\lib\net45\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\lib\net45\EFHooks.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\EFHooks\EFHooks.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.6.0.1\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.6.0.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServerCompact">
<HintPath>..\packages\EntityFramework.SqlServerCompact.6.0.1\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.SqlServer.Compact.4.0.8876.1\lib\net40\System.Data.SqlServerCe.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\EFHooks\HookedDbContext.cs">
<Link>HookedDbContext.cs</Link>
</Compile>
<Compile Include="..\EFHooks\HookedEntityEntry.cs">
<Link>HookedEntityEntry.cs</Link>
</Compile>
<Compile Include="..\EFHooks\HookEntityMetadata.cs">
<Link>HookEntityMetadata.cs</Link>
</Compile>
<Compile Include="..\EFHooks\IHook.cs">
<Link>IHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\IPostActionHook.cs">
<Link>IPostActionHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\IPreActionHook.cs">
<Link>IPreActionHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PostActionHook.cs">
<Link>PostActionHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PostDeleteHook.cs">
<Link>PostDeleteHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PostInsertHook.cs">
<Link>PostInsertHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PostUpdateHook.cs">
<Link>PostUpdateHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PreActionHook.cs">
<Link>PreActionHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PreDeleteHook.cs">
<Link>PreDeleteHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PreInsertHook.cs">
<Link>PreInsertHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\PreUpdateHook.cs">
<Link>PreUpdateHook.cs</Link>
</Compile>
<Compile Include="..\EFHooks\Properties\Constants.cs">
<Link>Properties\Constants.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\EFHooks\EFHooks.snk">
<Link>EFHooks.snk</Link>
</None>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup>
<PostBuildEvent>
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading