Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Cloning the Entity object and all related children using the Entity Framework

, 8 May 2012 CPOL
Cloning the Entity object and all its children using the Entity Framework, using LINQ and Reflection.
CloningSample.zip
CloningSample
CloningSample.suo
CloningSample.Tests
bin
Debug
CloningSample.dll
CloningSample.pdb
CloningSample.Tests.dll
CloningSample.Tests.pdb
Controllers
obj
Debug
CloningSample.Tests.csprojResolveAssemblyReference.cache
CloningSample.Tests.dll
CloningSample.Tests.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
CloningSample
App_Data
bin
CloningSample.dll
CloningSample.pdb
CloningSample.csproj.user
Content
Controllers
DBScripts
Global.asax
Models
EmpModel.edmx
obj
Debug
CloningSample.csprojResolveAssemblyReference.cache
CloningSample.dll
CloningSample.pdb
DesignTimeResolveAssemblyReferencesInput.cache
edmxResourcesToEmbed
Models
EmpModel.csdl
EmpModel.msl
EmpModel.ssdl
TempEdmx
TempPE
Models.EmpModel.Designer.cs.dll
Properties
Scripts
Views
Account
Employeemaster
Home
Shared
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{CEAAA2F1-DC10-494F-9C60-FC006E3378AC}</ProjectGuid>
    <ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CloningSample</RootNamespace>
    <AssemblyName>CloningSample</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <MvcBuildViews>false</MvcBuildViews>
    <TargetFrameworkProfile />
    <UseIISExpress>false</UseIISExpress>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</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\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Data.Services" />
    <Reference Include="System.Data.Services.Client" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Security" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.ServiceModel.Web" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.ComponentModel.DataAnnotations">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.Xml.Linq" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="CloneHelper.cs" />
    <Compile Include="Controllers\AccountController.cs" />
    <Compile Include="Controllers\HomeController.cs" />
    <Compile Include="Global.asax.cs">
      <DependentUpon>Global.asax</DependentUpon>
    </Compile>
    <Compile Include="Models\AccountModels.cs" />
    <Compile Include="Models\EmpModel.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>EmpModel.edmx</DependentUpon>
    </Compile>
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="DBScripts\EfcloningDB.sql" />
    <Content Include="Global.asax" />
    <Content Include="Views\Employeemaster\Employee.aspx" />
    <Content Include="Views\Employeemaster\EmployeeLIst.aspx" />
    <Content Include="Views\Employeemaster\Clone.aspx" />
    <Content Include="Views\Employeemaster\ViewPage1.aspx" />
    <Content Include="Web.config" />
    <Content Include="Web.Debug.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
    <Content Include="Web.Release.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
    <Content Include="Content\Site.css" />
    <Content Include="Scripts\jquery-1.4.1.js" />
    <Content Include="Scripts\jquery-1.4.1.min.js" />
    <Content Include="Scripts\jquery-1.4.1-vsdoc.js" />
    <Content Include="Scripts\jquery.validate.js" />
    <Content Include="Scripts\jquery.validate.min.js" />
    <Content Include="Scripts\jquery.validate-vsdoc.js" />
    <Content Include="Scripts\MicrosoftAjax.js" />
    <Content Include="Scripts\MicrosoftAjax.debug.js" />
    <Content Include="Scripts\MicrosoftMvcAjax.js" />
    <Content Include="Scripts\MicrosoftMvcAjax.debug.js" />
    <Content Include="Scripts\MicrosoftMvcValidation.js" />
    <Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
    <Content Include="Views\Account\ChangePassword.aspx" />
    <Content Include="Views\Account\ChangePasswordSuccess.aspx" />
    <Content Include="Views\Account\LogOn.aspx" />
    <Content Include="Views\Account\Register.aspx" />
    <Content Include="Views\Home\About.aspx" />
    <Content Include="Views\Home\Index.aspx" />
    <Content Include="Views\Shared\Error.aspx" />
    <Content Include="Views\Shared\LogOnUserControl.ascx" />
    <Content Include="Views\Shared\Site.Master" />
    <Content Include="Views\Web.config" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="App_Data\" />
  </ItemGroup>
  <ItemGroup>
    <EntityDeploy Include="Models\EmpModel.edmx">
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>EmpModel.Designer.cs</LastGenOutput>
    </EntityDeploy>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target> -->
  <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
  </Target>
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>False</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>51619</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>
          </IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Appusamy.subbian
Software Developer (Senior)
India India
No Biography provided
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 8 May 2012
Article Copyright 2010 by Appusamy.subbian
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid