不支持关键字:“服务器" [英] Keyword not supported: 'server'

查看:58
本文介绍了不支持关键字:“服务器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试编辑连接字符串以将我的网站上传到服务器.
我对此并没有真正的经验.我得到了这个例外:不支持的关键字:服务器".
这是我的连接字符串:

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" />

我尝试将此字符串嵌入到我的旧连接字符串中,该字符串在本地运行良好,但不适合:S

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

推荐答案

对于实体框架(数据库优先或模型优先;当您有物理 EDMX 模型文件时)您需要使用特殊类型的连接字符串,即与迄今为止其他人提到的直接 ADO.NET 连接字符串完全不同......

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" />

在此连接字符串中,您会找到 provider connection string= 属性,它基本上就是您的 ADO.NET 连接字符串:

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=.... 代表您的服务器(您也可以使用 server=.....)
  • initial catalog=..... 代表您的数据库(您也可以使用 database=....)
  • data source=.... stands for your server (you can also use server=.....)
  • initial catalog=..... stands for your database (you can also use database=....)

这篇关于不支持关键字:“服务器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆