Reputation: 23515
I'm getting an
"Activation error occured while trying to get instance of type Database, key "" "
exception with my DatabaseFactory.CreateDatabase()
whenever I reference the default database to a SQL Server CE
I tried checking if the problem is just my .dll reference, which I was able to prove wrong because I was still able to connect to a real SQL Server 2008 db.
Here's my config:
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</configSections>
<dataConfiguration defaultDatabase="sqlCEDB"/>
<connectionStrings>
<add name="sqlCEDB"
connectionString="Data Source=|DataDirectory|\sqlCEDB.sdf;Password='somepassword'"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
Here's how I create the database instance:
private Database db;
protected internal Database DB
{
get
{
if (db == null)
db = DatabaseFactory.CreateDatabase();
return db;
}
}
SOLUTION
change config property solved: providerName="System.Data.SqlServerCe.3.5"
Upvotes: 1
Views: 1569
Reputation: 23515
SOLUTION
change config property solved: providerName="System.Data.SqlServerCe.3.5"
<configSections>
<section name="dataConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="false"/>
</configSections>
<dataConfiguration defaultDatabase="sqlCEDB"/>
<connectionStrings>
<add name="sqlCEDB"
connectionString="Data Source=|DataDirectory|\sqlCEDB.sdf;Password='somepassword'"
providerName="System.Data.SqlServerCe.3.5" />
</connectionStrings>
Upvotes: 2