关键字不支持的数据源 [英] keyword not supported data source

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

问题描述

我有默认的会员数据库一个​​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中,创建新的数据库,导入有从previous .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-DEV\SQLEXPRESS;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=&quot;Data Source=SERVER\SQL2000;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=False&quot;" 
      providerName="System.Data.EntityClient" /> 
</connectionStrings>

您是丢失了所有的 =元和您的EF连接字符串中的providerName = 元素.... ..你基本上只能有什么包含在提供商连接字符串部分的。

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设计师应该创建一个有效的EF连接字符串你,在你的web.config或app.config中。

Using the EDMX designer should create a valid EF connection string for you, in your web.config or app.config.

马克

更新:好吧,我明白你想要做什么:你需要第二个ADO.NET连接字符串只为ASP.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-DEV\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;" 
     providerName="System.Data.SqlClient" />

如果您指定的providerName = System.Data.EntityClient ==> 实体框架连接字符串(与元数据=和一切)。

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屋!

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