Keyword not supported: 'server'

48,361

Solution 1

For Entity Framework (database-first or model-first; when you have a physical EDMX model file) you need to use a special type of connection string which is quite different from the straight ADO.NET connection strings everyone else has mentioned so far...

The connection string must look something like:

<add name="testEntities" 
     connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=test;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

Inside this connection string, you'll find the provider connection string= attribute which is basically your ADO.NET connection string:

provider connection string=&quot;data source=(local);initial catalog=test;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" 

So here, you need to change your server name and possibly other settings.

  • data source=.... stands for your server (you can also use server=.....)
  • initial catalog=..... stands for your database (you can also use database=....)

Solution 2

In MVC5 using EntityFramework 6.xx and Code First Approach

I had the same problem and I solved this by modifying my providerName

from

 providerName="System.Data.EntityClient"

to

providerName="System.Data.SqlClient"

Solution 3

This exception is thrown on azure websites when you store the connection string in the App Service itself (on the 'Application Settings' blade).

If the connection string is an Entity Framework connection string the quotes will be encoded as &quot; by default in your web.config file.

You need to change these back to actual quotes so the connection string can be parsed properly.

Solution 4

I always either run a connection wizard to build my string or I use connectionstrings.com.

Assuming SQL Server:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Comparing to yours it is very different.

Server=xx.xx.xxx.xxx,xxxx;Database=AlBayan;Uid=bayan;Password=xxxxx;

Solution 5

Same happened to me when using Rider IDE for a .net core 2.2 project. As Rider automatically sets up Sqlite in Startup.cs in the "ConfigureServices" method.

By changing

services.AddDbContext<ApplicationDbContext>(options =>
    options.**UseSqlite**(
        Configuration.GetConnectionString("DefaultConnection")));

into

services.AddDbContext<ApplicationDbContext>(options =>
    options.**UseSqlServer**(
        Configuration.GetConnectionString("DefaultConnection")));

issue was resolved. Of course, first you have to install nuget packages for EF SQLServer and add the connection string to appsettings.json.

Share:
48,361
Evanescence
Author by

Evanescence

Updated on October 15, 2020

Comments

  • Evanescence
    Evanescence over 3 years

    I've been trying to edit my connection string for uploading my website to a server.
    I am not really experienced with this. I got this exception: the Keyword not supported: 'server'.
    Here is my connection string:

    <add name="AlBayanEntities" connectionString="Server=xx.xx.xxx.xxx,xxxx;Database=AlBayan;Uid=bayan;Password=xxxxx;" providerName="System.Data.EntityClient" />
    

    I've tried embed this string into my old connection string which works very well locally, but it didn't fit : S