I was trying to use Hangfire.IO in my MVC ASP.NET boilerplate application and pasted this code in Startup.cs as explained here in tutorial
GlobalConfiguration.Configuration
.UseSqlServerStorage("bwavenueEntities"); //getting error here
app.UseHangfireDashboard();
app.UseHangfireServer();
But I am getting an error in above code
Server Error in '/' Application.
Keyword not supported: 'metadata'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Keyword not supported: 'metadata'.
Source Error:
Line 75:
Line 76: app.MapSignalR();
Line 77: GlobalConfiguration.Configuration
Line 78: .UseSqlServerStorage("bwavenueEntities");
Line 79:
Source File: E:\bwavenue\src\bwavenue.Web\App_Start\Startup.cs Line: 77
Can you explain how to resolve it? and why it is throwing this error here is my connection string
<add name="bwavenueEntities" connectionString="metadata=res://*/Model.DbModel.csdl|res://*/Model.DbModel.ssdl|res://*/Model.DbModel.msl;provider=System.Data.SqlClient;provider connection string="data source=Test-PC;initial catalog=bwavenue;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Thanks
The error, Keyword not supported: 'metadata' is because you are not passing correct connection string, you are passing Entity framework Connection string that contains a SQL Server connection string in its provider connection string
parameter. WebSecurity.InitializeDatabaseConnection expects a valid database connection string.
If you will pass connection string like this
<add name="bwavenueEntities" connectionString="data source=*****;initial catalog=*****;User ID=****;password=*****;MultipleActiveResultsets=True" providerName="System.Data.EntityClient" />
It should work after the changes
Another possible answer, If you're developing/maintaining an Azure WebApp, using a connection string saved in Azure's Application Settings.
Other than each connection string in the Application Settings is a dropdown for the connection string type - it's very easy to forget to set this to 'Custom' for Entity Framework values and leave it at the default (SQL Database) - which also causes the above error.
Or In some cases, it just works by changing provider name in connection string from
providerName="System.Data.SqlClient"
to
providerName="System.Data.EntityClient"
as it is an EF connection string.
If you are using Entity framework type connection string, then you need to skip "metadata"
if (connectionString.ToLower().StartsWith("metadata="))
{
System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder efBuilder = new System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder(connectionString);
connectionString = efBuilder.ProviderConnectionString;
}
Hope it helps.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly