C# EF 读取App.config连接字符串

在Entiites里面创建

using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using HRMS.Model;
namespace HRMS.SQLServerDAL
{
    public partial class Entities : DbContext
    {
        private static string connString = ConfigurationManager.ConnectionStrings["connString"].ToString();

        public Entities() : base(connString)
        {

        }

        public virtual DbSet<PD_Bank> PD_Bank { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }
    }
}

 

posted @ 2020-12-29 21:03  南秦岭  阅读(288)  评论(0编辑  收藏  举报