.Net框架的ado.Net实体对象模型初步使用
2017-07-14 17:37
183 查看
先创建一个控制台应用程序应用。然后按照以下图片所示顺序进行操作。
弹出安全警告的时候不必管它,一直点击确定,有可能会弹出几次(我的弹了2次)。
然后可以看到生成了2个类。
编写新增记录的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace orm1
{
class Program
{
static void Main(string[] args)
{
using (GDUsersAccountEntities entity = new GDUsersAccountEntities())
{
entity.UsersAccount.Add(new UsersAccount() { 用户名 = "12", 密码 = "123", 工站号 = "1234", 功能模块 = "1", 手机号 = "5" });
entity.SaveChanges();
}
}
}
}
然后登陆数据库,查看是否上传成功。
弹出安全警告的时候不必管它,一直点击确定,有可能会弹出几次(我的弹了2次)。
然后可以看到生成了2个类。
编写新增记录的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace orm1
{
class Program
{
static void Main(string[] args)
{
using (GDUsersAccountEntities entity = new GDUsersAccountEntities())
{
entity.UsersAccount.Add(new UsersAccount() { 用户名 = "12", 密码 = "123", 工站号 = "1234", 功能模块 = "1", 手机号 = "5" });
entity.SaveChanges();
}
}
}
}
然后登陆数据库,查看是否上传成功。
相关文章推荐
- ADO.NET 实体数据模型 异常-“序列化类型为 XX 的对象时检测到循环引用”
- ADO.NET Entity Framework 如何:使用存储过程定义模型(实体框架)
- ADO.NET 实体数据模型 异常-“序列化类型为 XX 的对象时检测到循环引用”
- 使用ADO.NET 实体数据模型实现SQL存储过程调用
- ADO.NET Entity Framework 如何:自定义建模和映射文件以使用自定义对象(实体框架)
- NBear.Mapping使用教程(4):实体对象与ADO.NET对象的转换
- ADO.NET Entity Framework 使用实体数据模型工具
- ADO.NET Entity Framework (实体模型框架) 一些使用的注意事项
- NBear.Mapping使用教程(4):实体对象与ADO.NET对象的转换
- ADO.NET Entity Framework如何:使用存储过程定义模型(实体框架)
- [转载]使用ADO.NET EntityFramework实体模型类
- ADO.NET实体数据模型使用探索1
- ADO.NET Entity Framework如何:使用实体数据模型向导(实体框架)
- 使用ADO.net 实体数据模型遇到的问题
- 趣味理解ADO.NET对象模型
- 趣味理解ADO.NET对象模型 系列二——进水笼头--建立Connection
- 趣味理解ADO.NET对象模型
- 趣味理解ADO.NET对象模型
- [2004-8-4]VB.Net学习笔记,使用ADO.Net对象访问数据库,将结果写入ListView
- 使用ADO.NET Entity Framework的实体作为数据源Data Source(附Demo程序下载)- 系列3