标签:pen max gif protect contex 创建 span pwd protected
1.新建空项目
2.创建实体类库
创建实体
public class UsersInfo { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] //设置自增 public int SeqNum { get; set; } [Key,MaxLength(50)] public string UserID { get; set; } //[Required]必填 [Required,MaxLength(50)] public string UserName { get; set; } [MaxLength(1)] public int Gender { get; set; } [MaxLength(50)] public string BelongClass { get; set; } [MaxLength(255)] public string Disc { get; set; } }
3.再创建一个类库项目
创建DemoContext类(与数据库交互)
public class DemoContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( connectionString: "server=.;database=MyTestDB;uid=sjz2018dbuser;pwd=1ECD9E*#E9DCE1;" ); } public DbSet<ClassInfo> ClassInfos { get; set; } public DbSet<UsersInfo> UsersInfos { get; set; } }
所引nuget包
Net Core + EF Core + Sql Server
标签:pen max gif protect contex 创建 span pwd protected
原文地址:https://www.cnblogs.com/JoeYD/p/13355179.html