dotnetnuke 中使用ado.net entityframework 如果在程序中动态调用系统的连接字符串信息

1,打开如下图的Model1.Context.cs文件

dotnetnuke 中使用ado.net entityframework 如果在程序中动态调用系统的连接字符串信息

 

2,找到

dotnetnuke 中使用ado.net entityframework 如果在程序中动态调用系统的连接字符串信息

Base:(ConnString.conn)是我改的。默认生成的是"name=实体连接字符串"

Connstring.conn代码如下:

  public static string conn

        {             get             {

                var dnnConnectStringBuilder = DotNetNuke.Data.DataProvider.Instance().GetConnectionStringBuilder();                 dnnConnectStringBuilder.ConnectionString = DotNetNuke.Data.DataProvider.Instance().ConnectionString;

                if (!dnnConnectStringBuilder.ContainsKey("MultipleActiveResultSets"))                 {                     dnnConnectStringBuilder.Add("MultipleActiveResultSets", true);                 }                 else                 {                     dnnConnectStringBuilder["MultipleActiveResultSets"] = true;                 }

                String connectionString = String.Format("metadata=res://*/Model.Model1.csdl|res://*/Model.Model1.ssdl|res://*/Model.Model1.msl;provider=System.Data.SqlClient;provider connection string=\"{0}\"", dnnConnectStringBuilder.ConnectionString);

                return connectionString;             }         }

 

你可能感兴趣的:(dotnetnuke)