【ORM】EF Code Only


一、我要使用,要怎么做?

使用EF需要设置主键,在Code Only下的操作:

添加引用EntityFrameWork.dll和EntityFrameWork.xml


写连接字符串(在配置文件.config中还要包含providerName),

自己的上下文类继承DbConext(连接字符串)

在设备上下文之中加入需要的表,还需要设置相应的主键,

还要using System.ComponentModel.DataAnnotations;  

添加引用System.ComponentModel.DataAnnotations

才能设置主键

public class xx

{

[Key]

属性;

}

二、为什么这样做?

猜你喜欢

转载自blog.csdn.net/qq_35315154/article/details/80450308
今日推荐