Trying to add a Controller with scaffolding and getting an error. Seems to have to do with my Connection String.
"unable to retrieve metadata for DOTNETMEMBER.Song. Failed to set database initializer type of type DOTNET.DataContextInitializer, DOTNETMEMBER' specified in the application configuration. Entries should be in the form of 'key=DatabaseInitializerForType MyNamespace.MydbContextClass, MyAssembly'. The initializer class must have parameterless constructor. See inner exception for details.
Here’s my connection string
<connectionStrings>
<add name="DataContext"
connectionString="Data Source=|DataDirectory|RTDOTNETMEMBER.sdf"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<!--Used to initialize the database-->
<add key="DatabaseInitializerForType DOTNET.DataContext, DOTNETMEMBER" value="DOTNET.DataContextInitializer, DOTNETMEMBER" />
</appSettings>
Is it because of SQL Compact?
I’m afraid this isn’t a comprehensive answer because I don’t fully understand the reasons why, but when I ran into the same issue this workaround allowed me to just get on with things and stop scratching my head:
DatabaseInitializerForTypekey (shortcut: place your cursor on the line then ctrl-K and ctrl-C).Yes, it’s a bit of a random-stab-in-the-dark approach, but I’ll leave it here in case it helps anyone else googling the same issue!