entity framework EntityConnectionStringBuilder in asp.net c#
Entity Framework Connection String
Pass connection string run time in entity frameworkpublic string GetConnectionString() { string connectionstring = "DATA SOURCE=lesson8;PASSWORD=lesson8;PERSIST SECURITY INFO=True;USER ID=lesson8"; EntityConnectionStringBuilder newconnstring = new EntityConnectionStringBuilder(); newconnstring.Metadata = @"res://*/lesson8Reports.csdl|res://*/lesson8Reports.ssdl|res://*/lesson8Reports.msl";//@"res://*/"; newconnstring.Provider = "System.Data.SqlClient"; // Oracle.DataAccess.Client newconnstring.ProviderConnectionString = connectionstring; return newconnstring.ToString(); }
use
myEntity _ent = new myEntity(GetConnectionString());
if your data provider in sql than add in provider
System.Data.SqlClient
or provider in oracle than add to
Oracle.DataAccess.Client
entity framework EntityConnectionStringBuilder in asp.net c#
Reviewed by Bhaumik Patel
on
6:37 AM
Rating: