[英]Same databases on different servers
Maybe the title of this question isn't very helpful or might be off topic... I have created mySQL database which has the same name and the same table as the mySQL database I was given by the server where I'm hosting my app. 也许这个问题的标题不是很有帮助,或者可能不在主题...我创建了mySQL数据库,它与mySQL数据库具有相同的名称和相同的表我是由我托管我的应用程序的服务器给出的。
In my Asp.net project I use my database and use Entity Framework. 在我的Asp.net项目中,我使用我的数据库并使用Entity Framework。
So with two different tables that have the same names and same tables it's just the connString(or is it?), my question would be, how do I let my website know that he should use the database on this server? 所以有两个不同的表具有相同的名称和相同的表,它只是connString(或者是它?),我的问题是,如何让我的网站知道他应该在这台服务器上使用数据库?
I asked the support of my host for help their reply was:"Sorry we have no experience in Your framework"!! 我请求主人的支持,他们的答复是:“抱歉,我们没有你的框架经验”!!
So this is where I have to turn for help. 所以这是我必须寻求帮助的地方。
EDIT: 编辑:
<add name="tuuletfi_tidmediacafeEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=aleksalukic;database=tuuletfi_tidmediacafe"" providerName="System.Data.EntityClient" />
this is my entire connection string for the VS2015 这是我VS2015的整个连接字符串
Also I access the server DB with phpMyAdmin. 我也用phpMyAdmin访问服务器数据库。
You have to set the ConnectionString on your Web.Config: 您必须在Web.Config上设置ConnectionString:
https://msdn.microsoft.com/en-us/library/jj556606(v=vs.113).aspx https://msdn.microsoft.com/en-us/library/jj556606(v=vs.113).aspx
Has you try with a connection string like this 你试过像这样的连接字符串吗?
UPDATE this is extract from my webconfig pls check MYSQL driver version compliant with yours 更新这是从我的webconfig中提取的请检查与您的MYSQL驱动程序版本兼容
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers>
<add name="mysql" connectionString="server=x.x.x.x;User Id=root;password=123456;database=appdb;pooling=false;" providerName="MySql.Data.MySqlClient" />
... before and of configuration ......之前和配置
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
Change db/usr/pass with your data 使用您的数据更改db / usr / pass
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.