关键字不受支持的数据源 [英] keyword not supported data source
问题描述
我有一个带有默认成员资格数据库的 asp.net-mvc 应用程序.我通过 ADO.NET 实体框架访问它.
I have an asp.net-mvc application with the default membership database. I am accessing it by ADO.NET Entity Framework.
现在我想把它移到 IIS,但是出现了几个问题.我必须安装 SQL Server Management Studio,创建新数据库,然后从以前的 .MDF 文件中导入所有数据.剩下要做的唯一事情(据我所知)是更改为连接字符串.但是,我对此并没有真正的经验,并且一直不支持关键字:数据源".例外.这是我的连接字符串:
Now I want to move it to IIS, but several problems showed up. I had to install SQL Server Management Studio, Create new DB, import there all the data from the previous .MDF file. Only thing left to do (as far a I know) is to change to connection string. However, I am not really experienced with this and keep getting the Keyword not supported: 'data source'. exception. Here is my connection string:
<add name="ASPNETDBEntities"
connectionString="Data Source=MONTGOMERY-DEVSQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;"
providerName="System.Data.EntityClient" />
有什么想法,有什么问题吗?
Any ideas, what's wrong?
推荐答案
您拥有的是有效的 ADO.NET 连接字符串 - 但它不是有效的实体框架连接字符串.
What you have is a valid ADO.NET connection string - but it's NOT a valid Entity Framework connection string.
EF 连接字符串看起来像这样:
The EF connection string would look something like this:
<connectionStrings>
<add name="NorthwindEntities" connectionString=
"metadata=.Northwind.csdl|.Northwind.ssdl|.Northwind.msl;
provider=System.Data.SqlClient;
provider connection string="Data Source=SERVERSQL2000;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=False""
providerName="System.Data.EntityClient" />
</connectionStrings>
您缺少 EF 连接字符串中的所有 metadata=
和 providerName=
元素……您基本上只有 provider 连接字符串
部分.
You're missing all the metadata=
and providerName=
elements in your EF connection string...... you basically only have what's contained in the provider connection string
part.
使用 EDMX 设计器应该会在您的 web.config 或 app.config 中为您创建一个有效的 EF 连接字符串.
Using the EDMX designer should create a valid EF connection string for you, in your web.config or app.config.
马克
更新:好的,我明白您要做什么:您需要一个仅用于 ASP.NET 用户/成员资格数据库的第二个ADO.NET"连接字符串.您的字符串没问题,但 providerName 是错误的——它必须是System.Data.SqlClient"——这个连接不使用实体框架——然后不要为它指定EntityClient"!
UPDATE: OK, I understand what you're trying to do: you need a second "ADO.NET" connection string just for ASP.NET user / membership database. Your string is OK, but the providerName is wrong - it would have to be "System.Data.SqlClient" - this connection doesn't use ENtity Framework - don't specify the "EntityClient" for it then!
<add name="ASPNETMembership"
connectionString="Data Source=MONTGOMERY-DEVSQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;"
providerName="System.Data.SqlClient" />
如果您指定 providerName=System.Data.EntityClient
==> Entity Framework 连接字符串(带有 metadata= 和所有内容).
If you specify providerName=System.Data.EntityClient
==> Entity Framework connection string (with the metadata= and everything).
如果您需要并指定providerName=System.Data.SqlClient
==> 直接ADO.NET SQL Server 连接字符串,没有添加所有EF
If you need and specify providerName=System.Data.SqlClient
==> straight ADO.NET SQL Server connection string without all the EF additions
这篇关于关键字不受支持的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!