本实例包含EFCodeFirst分别SQLServer和MySQL数据的使用。Code First模式我们称之为“代码优先”模式,是从EF4.1开始新建加入的功能。使用Code First模式进行EF开发时开发人员只需要编写对应的数据类(其实就是领域模型的实现过程),然后自动生成数据库。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 70144 2018-12-20 11:13 EFCodeFirst.vsEFCodeFirstv14.suo
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLApp.config
文件 7168 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.exe
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.exe.config
文件 17920 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.pdb
文件 22696 2018-12-20 11:08 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.vshost.exe
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.vshost.exe.config
文件 5062304 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityframework.dll
文件 580768 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityframework.SqlServer.dll
文件 334304 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityframework.SqlServer.xml
文件 6875415 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityframework.xml
文件 431616 2018-04-26 23:48 EFCodeFirstCodeFirstByMySQLinDebugMySql.Data.dll
文件 392704 2018-04-26 23:48 EFCodeFirstCodeFirstByMySQLinDebugMySql.Data.Entity.EF6.dll
文件 4097 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLCodeFirstByMySQL.csproj
文件 376 2018-12-20 10:50 EFCodeFirstCodeFirstByMySQLModelCard.cs
文件 477 2018-12-20 10:39 EFCodeFirstCodeFirstByMySQLModelCodeFirsByMySQLtContext.cs
文件 372 2018-12-20 10:50 EFCodeFirstCodeFirstByMySQLModelUser.cs
文件 943 2018-12-20 11:08 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.csproj.FileListAbsolute.txt
文件 34898 2018-12-20 10:42 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.csprojResolveAssemblyReference.cache
文件 7168 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.exe
文件 17920 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.pdb
文件 7321 2018-12-20 10:55 EFCodeFirstCodeFirstByMySQLobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 296 2018-12-20 10:35 EFCodeFirstCodeFirstByMySQLpackages.config
文件 701 2018-12-20 10:39 EFCodeFirstCodeFirstByMySQLProgram.cs
文件 1358 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLPropertiesAssemblyInfo.cs
文件 1191 2018-12-18 11:30 EFCodeFirstEFCodeFirstApp.config
文件 6144 2018-12-18 11:31 EFCodeFirstEFCodeFirstinDebugEFCodeFirst.exe
............此处省略100个文件信息
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.vsEFCodeFirstv14.suo
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLApp.config
文件 7168 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.exe
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.exe.config
文件 17920 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.pdb
文件 22696 2018-12-20 11:08 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.vshost.exe
文件 1903 2018-12-20 11:07 EFCodeFirstCodeFirstByMySQLinDebugCodeFirstByMySQL.vshost.exe.config
文件 5062304 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityfr
文件 580768 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityfr
文件 334304 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityfr
文件 6875415 2013-09-11 09:10 EFCodeFirstCodeFirstByMySQLinDebugEntityfr
文件 431616 2018-04-26 23:48 EFCodeFirstCodeFirstByMySQLinDebugMySql.Data.dll
文件 392704 2018-04-26 23:48 EFCodeFirstCodeFirstByMySQLinDebugMySql.Data.Entity.EF6.dll
文件 4097 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLCodeFirstByMySQL.csproj
文件 376 2018-12-20 10:50 EFCodeFirstCodeFirstByMySQLModelCard.cs
文件 477 2018-12-20 10:39 EFCodeFirstCodeFirstByMySQLModelCodeFirsByMySQLtContext.cs
文件 372 2018-12-20 10:50 EFCodeFirstCodeFirstByMySQLModelUser.cs
文件 943 2018-12-20 11:08 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.csproj.FileListAbsolute.txt
文件 34898 2018-12-20 10:42 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.csprojResolveAssemblyReference.cache
文件 7168 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.exe
文件 17920 2018-12-20 11:01 EFCodeFirstCodeFirstByMySQLobjDebugCodeFirstByMySQL.pdb
文件 7321 2018-12-20 10:55 EFCodeFirstCodeFirstByMySQLobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLobjDebugTemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 296 2018-12-20 10:35 EFCodeFirstCodeFirstByMySQLpackages.config
文件 701 2018-12-20 10:39 EFCodeFirstCodeFirstByMySQLProgram.cs
文件 1358 2018-12-20 10:26 EFCodeFirstCodeFirstByMySQLPropertiesAssemblyInfo.cs
文件 1191 2018-12-18 11:30 EFCodeFirstEFCodeFirstApp.config
文件 6144 2018-12-18 11:31 EFCodeFirstEFCodeFirstinDebugEFCodeFirst.exe
............此处省略100个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)