How to create programmatically conncetion string without entity metadata in code first approch -
i trying create connection string programmatically got error need configure metatdata nama & when using code first approach don't have @adventureworksmodel.ssdl|///adventureworksmodel.csdl res:///adventurdventureworksmodel.msl"; how able configure connection string
some code on trying
sqlconnectionstringbuilder sqlconnectionbuilder = new sqlconnectionstringbuilder(); sqlconnectionbuilder.datasource = @"10.103.201.31"; sqlconnectionbuilder.initialcatalog = database; sqlconnectionbuilder.integratedsecurity = true; sqlconnectionbuilder.multipleactiveresultsets = true; string sqlconnectionstring = sqlconnectionbuilder.connectionstring; //initialize entityconnectionstringbuilder entityconnectionstringbuilder entitybuilder = new entityconnectionstringbuilder(); entitybuilder.provider = "system.data.sqlclient"; entitybuilder.providerconnectionstring = sqlconnectionstring; //set metadata location. entitybuilder.metadata = @"res://*/"; //create entity connection entityconnection connection = new entityconnection(entitybuilder.connectionstring); return new sqlcodefirstcontext(connection);
Comments
Post a Comment