Corporate library 4 dataconfiguration tags

I use the corporate library to access data. When I launch the application, in the CreateDatabase () statement, I get this exception:

Microsoft.Practices.ObjectBuilder2.BuildFailedException was not handled by user code Message = "The current build operation (build the Build key [Microsoft.Practices.EnterpriseLibrary.Data.Database, null] key) failed: The value cannot be empty or empty. (Type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy strategy, index 2) "Source =" Microsoft.Practices.ObjectBuilder2 "

Now I was looking a bit googled and I found that I need to post

<dataConfiguration defaultDatabase="LocalSqlServer"/> 

but I don’t know where. This is the right decision?

Also, during the installation of the corporate library, I did not see the connection string instructions? So, I wonder how this will take the connection string from the web.config file.

In the connection string line of my web.config file, I have:

 <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=MSTR;Initial Catalog=USERDb;Integrated Security=true;" providerName="System.Data.SqlClient"/> 
+4
source share
1 answer

Yes you need to add the dataConfiguration section to web.config.

First you need to add dataConfiguration to the ConfigurationSections list in your web.config:

 <configSections> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </configSections> 

Then you need to add your connection lines to web.config (you've already done this):

 <connectionStrings> <add name="LocalSqlServer" connectionString="Data Source=MSTR;Initial Catalog=USERDb;Integrated Security=true;" providerName="System.Data.SqlClient"/> </connectionStrings> 

Then you need to add the actual DataConfiguration section to web.config:

 <dataConfiguration defaultDatabase="LocalSqlServer"/> 

You can also use the corporate library customization tool to do this for you.

+6
source

Source: https://habr.com/ru/post/1336984/


All Articles