Skip to content

Commit 0af6fca

Browse files
Initial project upload
1 parent a3d9744 commit 0af6fca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5003
-0
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

CodeLab.Assets.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.15
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFUpdateWrapper", "EFUpdateWrapper\EFUpdateWrapper.csproj", "{FEB70436-681B-4376-AE7C-75CB22FFB547}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateWrapperTest", "UpdateWrapperTest\UpdateWrapperTest.csproj", "{86181326-FCE6-4AD5-83D6-757CF2495A31}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFDefaultUpdate", "EFDefaultUpdate\EFDefaultUpdate.csproj", "{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{FEB70436-681B-4376-AE7C-75CB22FFB547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{FEB70436-681B-4376-AE7C-75CB22FFB547}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{FEB70436-681B-4376-AE7C-75CB22FFB547}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{FEB70436-681B-4376-AE7C-75CB22FFB547}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{86181326-FCE6-4AD5-83D6-757CF2495A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{86181326-FCE6-4AD5-83D6-757CF2495A31}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{86181326-FCE6-4AD5-83D6-757CF2495A31}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{86181326-FCE6-4AD5-83D6-757CF2495A31}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
EndGlobal

EFDefaultUpdate/App.config

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
6+
</configSections>
7+
<startup>
8+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
9+
</startup>
10+
<connectionStrings>
11+
<add name="BookLibraryEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqldev16;initial catalog=BookLibrary;persist security info=True;user id=sa;password=123456280;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
12+
</connectionStrings>
13+
<entityFramework>
14+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
15+
<parameters>
16+
<parameter value="mssqllocaldb" />
17+
</parameters>
18+
</defaultConnectionFactory>
19+
<providers>
20+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
21+
</providers>
22+
</entityFramework>
23+
</configuration>

EFDefaultUpdate/Book.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace EFDefaultUpdate
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
public partial class Book
16+
{
17+
public int ID { get; set; }
18+
public string Name { get; set; }
19+
public string Author { get; set; }
20+
public int Category { get; set; }
21+
22+
public virtual BookCategory BookCategory { get; set; }
23+
}
24+
}

EFDefaultUpdate/BookCategory.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace EFDefaultUpdate
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
public partial class BookCategory
16+
{
17+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
18+
public BookCategory()
19+
{
20+
this.Books = new HashSet<Book>();
21+
}
22+
23+
public int ID { get; set; }
24+
public string Name { get; set; }
25+
26+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
27+
public virtual ICollection<Book> Books { get; set; }
28+
}
29+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{09A6EEDA-57E6-483C-ACAA-CE05A9AB0B75}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>EFDefaultUpdate</RootNamespace>
10+
<AssemblyName>EFDefaultUpdate</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
36+
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
37+
</Reference>
38+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
39+
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
40+
</Reference>
41+
<Reference Include="System" />
42+
<Reference Include="System.ComponentModel.DataAnnotations" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.Runtime.Serialization" />
45+
<Reference Include="System.Security" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="Microsoft.CSharp" />
49+
<Reference Include="System.Data" />
50+
<Reference Include="System.Deployment" />
51+
<Reference Include="System.Drawing" />
52+
<Reference Include="System.Net.Http" />
53+
<Reference Include="System.Windows.Forms" />
54+
<Reference Include="System.Xml" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Compile Include="Book.cs">
58+
<DependentUpon>Model1.tt</DependentUpon>
59+
</Compile>
60+
<Compile Include="BookCategory.cs">
61+
<DependentUpon>Model1.tt</DependentUpon>
62+
</Compile>
63+
<Compile Include="Form1.cs">
64+
<SubType>Form</SubType>
65+
</Compile>
66+
<Compile Include="Form1.Designer.cs">
67+
<DependentUpon>Form1.cs</DependentUpon>
68+
</Compile>
69+
<Compile Include="Model1.Context.cs">
70+
<AutoGen>True</AutoGen>
71+
<DesignTime>True</DesignTime>
72+
<DependentUpon>Model1.Context.tt</DependentUpon>
73+
</Compile>
74+
<Compile Include="Model1.cs">
75+
<AutoGen>True</AutoGen>
76+
<DesignTime>True</DesignTime>
77+
<DependentUpon>Model1.tt</DependentUpon>
78+
</Compile>
79+
<Compile Include="Model1.Designer.cs">
80+
<AutoGen>True</AutoGen>
81+
<DesignTime>True</DesignTime>
82+
<DependentUpon>Model1.edmx</DependentUpon>
83+
</Compile>
84+
<Compile Include="Program.cs" />
85+
<Compile Include="Properties\AssemblyInfo.cs" />
86+
<EmbeddedResource Include="Form1.resx">
87+
<DependentUpon>Form1.cs</DependentUpon>
88+
</EmbeddedResource>
89+
<EmbeddedResource Include="Properties\Resources.resx">
90+
<Generator>ResXFileCodeGenerator</Generator>
91+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
92+
<SubType>Designer</SubType>
93+
</EmbeddedResource>
94+
<Compile Include="Properties\Resources.Designer.cs">
95+
<AutoGen>True</AutoGen>
96+
<DependentUpon>Resources.resx</DependentUpon>
97+
</Compile>
98+
<EntityDeploy Include="Model1.edmx">
99+
<Generator>EntityModelCodeGenerator</Generator>
100+
<LastGenOutput>Model1.Designer.cs</LastGenOutput>
101+
</EntityDeploy>
102+
<None Include="Model1.edmx.diagram">
103+
<DependentUpon>Model1.edmx</DependentUpon>
104+
</None>
105+
<None Include="packages.config" />
106+
<None Include="Properties\Settings.settings">
107+
<Generator>SettingsSingleFileGenerator</Generator>
108+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
109+
</None>
110+
<Compile Include="Properties\Settings.Designer.cs">
111+
<AutoGen>True</AutoGen>
112+
<DependentUpon>Settings.settings</DependentUpon>
113+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
114+
</Compile>
115+
</ItemGroup>
116+
<ItemGroup>
117+
<None Include="App.config" />
118+
</ItemGroup>
119+
<ItemGroup>
120+
<Content Include="Model1.Context.tt">
121+
<Generator>TextTemplatingFileGenerator</Generator>
122+
<LastGenOutput>Model1.Context.cs</LastGenOutput>
123+
<DependentUpon>Model1.edmx</DependentUpon>
124+
</Content>
125+
<Content Include="Model1.tt">
126+
<Generator>TextTemplatingFileGenerator</Generator>
127+
<DependentUpon>Model1.edmx</DependentUpon>
128+
<LastGenOutput>Model1.cs</LastGenOutput>
129+
</Content>
130+
</ItemGroup>
131+
<ItemGroup>
132+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
133+
</ItemGroup>
134+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
135+
</Project>

EFDefaultUpdate/Form1.Designer.cs

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EFDefaultUpdate/Form1.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
11+
namespace EFDefaultUpdate
12+
{
13+
public partial class Form1 : Form
14+
{
15+
public Form1()
16+
{
17+
InitializeComponent();
18+
}
19+
20+
private void button1_Click(object sender, EventArgs e)
21+
{
22+
BookLibraryEntities ctx = new BookLibraryEntities();
23+
Book b = ctx.Books.First(bk => bk.ID == 1);
24+
b.Author = "My Updated Author";
25+
ctx.SaveChanges();
26+
27+
//=========================
28+
29+
30+
}
31+
32+
private void button2_Click(object sender, EventArgs e)
33+
{
34+
35+
try
36+
{
37+
BookLibraryEntities ctx = new BookLibraryEntities();
38+
Book b = new Book();
39+
b.ID = 1;
40+
ctx.Books.Attach(b);
41+
b.Author = "My Updated Author2";
42+
ctx.SaveChanges();
43+
44+
45+
}
46+
catch (System.Data.Entity.Validation.DbEntityValidationException ex)
47+
{
48+
49+
}
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)