不支持关键字:“服务器"

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

问题描述

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

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=....)

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)