I have been searching for a few hours now and the closest I have came to fixing it is have found this solution but I cannot seem to get it to work in my project.
I am trying to upload a .CSV file and add the contents of the .CSV file to my database. (I am using a Local Database). When I upload the file I get an error
System.ArgumentException: 'Keyword not supported: 'metadata'.
From the answer in the link I have provided the problem is because "The string you passed is not a valid database connection string, it's an EF connection string that contains a SQL Server connection string in its provider connection string parameter." but I am not sure how I can fix this.
My connection string is:
<add name="MyDatabaseEntities" connectionString="metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\MyDatabase.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
This is the code in my controller where I am trying to connect to the database
string conString = ConfigurationManager.ConnectionStrings
["MyDatabaseEntities"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
{
//Set the database table name.
sqlBulkCopy.DestinationTableName = "dbo.Orders";
Can someone please tell me how to fix this issue, any help is greatly appreciated.