Getting started with the Enterprise Library v5.0, and getting an error when trying to use the createdatabase function

Topics: Data Access Application Block
Jan 29, 2015 at 6:03 PM
Hi all, I am trying to use the CreateDatabase function using the name of one of the databases that I have in my app.config file. However, I keep getting an error:

Activation error occured while trying to get instance of type Database, key

The inner exception is

Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "MYDBEntities".
Exception occurred while: while resolving.

Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.

At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,MYDBEntities

in my app.config file I do have an entry for this database that states:

<add name="MYDBEntities" connectionString="metadata=res:///PredictionModel.csdl|res:///PredictionModel.ssdl|res://*/PredictionModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SQLDEV01\SQLDEV02;Initial Catalog=ADPREDICTION;Persist Security Info=True;Connection Timeout=120;Trusted_Connection=Yes;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />

The code that I use to create this using the enterprise library is:
          Database mdb = DatabaseFactory.CreateDatabase("MYDBEntities");
Can someone help me out with this? I have been searching the internet, and applying the recommendations, but I have not had any progress.

Thanks!