資源簡介
本實例包含EFCodeFirst分別SQLServer和MySQL數據的使用。Code First模式我們稱之為“代碼優先”模式,是從EF4.1開始新建加入的功能。使用Code First模式進行EF開發時開發人員只需要編寫對應的數據類(其實就是領域模型的實現過程),然后自動生成數據庫。
代碼片段和文件信息
using?CodeFirstByMySQL.Model;
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?CodeFirstByMySQL
{
????class?Program
????{
????????static?void?Main(string[]?args)
????????{
????????????CodeFirsByMySQLtContext?dbcontext?=?new?CodeFirsByMySQLtContext();
????????????User?u?=?new?User();
????????????u.Name?=?“wang“;
????????????u.Id?=?1;
????????????Card?c?=?new?Card();
????????????c.CardName?=?“lei“;
????????????c.Id?=?1;
????????????//將實體賦予上下文,并添加到表里
????????????dbcontext.User.Add(u);
????????????//保存
????????????dbcontext.SaveChanges();
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????70144??2018-12-20?11:13??EFCodeFirst\.vs\EFCodeFirst\v14\.suo
?????文件???????1903??2018-12-20?11:07??EFCodeFirst\CodeFirstByMySQL\App.config
?????文件???????7168??2018-12-20?11:01??EFCodeFirst\CodeFirstByMySQL\bin\Debug\CodeFirstByMySQL.exe
?????文件???????1903??2018-12-20?11:07??EFCodeFirst\CodeFirstByMySQL\bin\Debug\CodeFirstByMySQL.exe.config
?????文件??????17920??2018-12-20?11:01??EFCodeFirst\CodeFirstByMySQL\bin\Debug\CodeFirstByMySQL.pdb
?????文件??????22696??2018-12-20?11:08??EFCodeFirst\CodeFirstByMySQL\bin\Debug\CodeFirstByMySQL.vshost.exe
?????文件???????1903??2018-12-20?11:07??EFCodeFirst\CodeFirstByMySQL\bin\Debug\CodeFirstByMySQL.vshost.exe.config
?????文件????5062304??2013-09-11?09:10??EFCodeFirst\CodeFirstByMySQL\bin\Debug\Entityfr
?????文件?????580768??2013-09-11?09:10??EFCodeFirst\CodeFirstByMySQL\bin\Debug\Entityfr
?????文件?????334304??2013-09-11?09:10??EFCodeFirst\CodeFirstByMySQL\bin\Debug\Entityfr
?????文件????6875415??2013-09-11?09:10??EFCodeFirst\CodeFirstByMySQL\bin\Debug\Entityfr
?????文件?????431616??2018-04-26?23:48??EFCodeFirst\CodeFirstByMySQL\bin\Debug\MySql.Data.dll
?????文件?????392704??2018-04-26?23:48??EFCodeFirst\CodeFirstByMySQL\bin\Debug\MySql.Data.Entity.EF6.dll
?????文件???????4097??2018-12-20?11:01??EFCodeFirst\CodeFirstByMySQL\CodeFirstByMySQL.csproj
?????文件????????376??2018-12-20?10:50??EFCodeFirst\CodeFirstByMySQL\Model\Card.cs
?????文件????????477??2018-12-20?10:39??EFCodeFirst\CodeFirstByMySQL\Model\CodeFirsByMySQLtContext.cs
?????文件????????372??2018-12-20?10:50??EFCodeFirst\CodeFirstByMySQL\Model\User.cs
?????文件????????943??2018-12-20?11:08??EFCodeFirst\CodeFirstByMySQL\obj\Debug\CodeFirstByMySQL.csproj.FileListAbsolute.txt
?????文件??????34898??2018-12-20?10:42??EFCodeFirst\CodeFirstByMySQL\obj\Debug\CodeFirstByMySQL.csprojResolveAssemblyReference.cache
?????文件???????7168??2018-12-20?11:01??EFCodeFirst\CodeFirstByMySQL\obj\Debug\CodeFirstByMySQL.exe
?????文件??????17920??2018-12-20?11:01??EFCodeFirst\CodeFirstByMySQL\obj\Debug\CodeFirstByMySQL.pdb
?????文件???????7321??2018-12-20?10:55??EFCodeFirst\CodeFirstByMySQL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????????0??2018-12-20?10:26??EFCodeFirst\CodeFirstByMySQL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2018-12-20?10:26??EFCodeFirst\CodeFirstByMySQL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2018-12-20?10:26??EFCodeFirst\CodeFirstByMySQL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件????????296??2018-12-20?10:35??EFCodeFirst\CodeFirstByMySQL\packages.config
?????文件????????701??2018-12-20?10:39??EFCodeFirst\CodeFirstByMySQL\Program.cs
?????文件???????1358??2018-12-20?10:26??EFCodeFirst\CodeFirstByMySQL\Properties\AssemblyInfo.cs
?????文件???????1191??2018-12-18?11:30??EFCodeFirst\EFCodeFirst\App.config
?????文件???????6144??2018-12-18?11:31??EFCodeFirst\EFCodeFirst\bin\Debug\EFCodeFirst.exe
............此處省略100個文件信息
- 上一篇:SSH增刪改查
- 下一篇:SQL 基礎教程 + 目錄 + 高清掃描版
評論
共有 條評論