The requested database user id=id; password=password; data source=source; is not defined in configuration.

Topics: Data Access Application Block
Dec 17, 2010 at 7:26 AM

Good day experts!

I have this in my Web.config:

<configSections> 
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" /> 
</configSections> 
<dataConfiguration defaultDatabase="MyConnString"/> 
<connectionStrings> 
<add name="MyConnString" connectionString="user id=id; password=password; data source=source;" providerName="System.Data.OracleClient" /> 
</connectionStrings> 
 
In my codes, when i say DatabaseFactory.CreateDatabase(), it works and it correctly connects to the Oracle Database. But when i say DatabaseFactory.CreateDatabase("MyConnString"), it gives back the error The requested database user id=id; password=password; data source=source; is not defined in configuration.
 

Am I missing anything?

Thanks in Advance

Dec 17, 2010 at 11:43 AM

Unfortunately I'm unable to reproduce your problem. Can you try supplying the assembly fullname for your Data assembly in the config section - "Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Also, can you send us a sample repro project for this (entlib.support@avanade.com). Thanks.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 22, 2010 at 1:48 AM

Here is an updated sample project https://docs.google.com/leaf?id=0BzB4vSfhA5DLOTUwZGQxZTUtOWJmOC00ZjU5LTlmMWUtMjdiM2I5MjRhZGVi&hl=en (this time around i used an embedded sql server)

Would you say that my configurations are correct?

I installed the source and i'm getting the error here    

 private void AddValidationExtension()
        {
            // We load this by name so we don't have a hard dependency from common -> validation
            const string partialExtensionTypeName = "Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Unity.ValidationBlockExtension, Microsoft.Practices.EnterpriseLibrary.Validation";
            const string fullExtensionTypeName =
                "Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Unity.ValidationBlockExtension, Microsoft.Practices.EnterpriseLibrary.Validation, Culture=neutral, Version=5.0.414.0, PublicKeyToken=31bf3856ad364e35";
            Type extensionType = Type.GetType(partialExtensionTypeName) ?? Type.GetType(fullExtensionTypeName);
            if (extensionType != null && container.Configure(extensionType) == null)
            {
                var vabExtension = (UnityContainerExtension)Activator.CreateInstance(extensionType);
                container.AddExtension(vabExtension); // Here
            }
        }

From there i get this error: Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider'.

Dec 22, 2010 at 2:26 AM

Now, in the updated sample project, I'm getting the ActivationException and this is because the John2 connection string's providerName attribute is specified as System.Data.SqlServerCe.Client.3.5 when the only available provider on my end is System.Data.SqlServerCe.3.5.  I used this then instead of the first one and didn't get the ActivationException.  The exception I get though is "System.NotSupportedException: SQL Server Compact is not intended for ASP.NET development.".  Do you still have issue on the CreateDatabase call?  Because I'm not sure if the code you posted is still relevant to the sample project or if it's now a totally different topic.  If this is a different one, please create a new discussion for it.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 22, 2010 at 2:49 AM

Well, it is relevant because it's giving me the same error.

Dec 22, 2010 at 3:29 AM

I'm confused,  the exceptions you mentioned are different.  the first one was the ActivationException and the second one is I'm not sure if it's also an ActivationException but still, they don't have the same error message.  Anyway, copying and pasting your code doesn't throw an exception for me.  Are you referencing the Validation and Data assembly from GAC?  Because if yes, it's a known issue in EntLib 5.0 and the workaround is posted in this item in the Issue Tracker.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 22, 2010 at 3:44 AM

The first error -- Activation Exception

I tried both referencing from the GAC and copying them locally and referencing from there.

I referenced .Data, .Common and .Validation; is there anything else that i'm missing?

The second error is what i get when i installed the EntLib50Src and referenced from that the source projects in EntLib50Scr when i was trying to step into the EntLib source.

 

Dec 22, 2010 at 4:00 AM

Ok, confirm if you're really no longer referencing the assembly from GAC by clicking on the reference and see that the Copy Local property is set to True.  A false value means it's still loading the assembly from GAC. 

On the next error, if you referenced the binaries from the source code, your config should also use the configuration tool from there.  Or modify your config so it doesn't include the Version, Culture, and PublicKeyToken attributes of the Entlib assemblies.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 22, 2010 at 5:44 AM

Wow. That pretty much solved it. Thanks for putting up with me :)