两个项目使用一个数据库文件,如何在两个项目中配置connectionStrings? [英] two Projects use one Database file,how config the connectionStrings in the two projects?

查看:71
本文介绍了两个项目使用一个数据库文件,如何在两个项目中配置connectionStrings?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

asp.net mvc3有两个项目,一个是前端,另一个是后端,用于管理数据库.

前端项目的路径为D:\ MyProject \ ArticleCMS \ ArticleCMS
Web.config路径:D:\ MyProject \ ArticleCMS \ ArticleCMS \ Web.config

后端项目的路径为D:\ MyProject \ ArticleCMS \ ArticleManage
Web.config路径:D:\ MyProject \ ArticleCMS \ ArticleManage \ Web.config

并且数据库文件的路径为D:\ MyProject \ ArticleCMS \ ArticleCMS \ App_Data \ ArticleCMS.mdf

在我的前端项目Web.config中,connectionStrings

There are two project by asp.net mvc3 ,one is frontend and the other is backend to manage the database.

Frontend project ''s path is D:\MyProject\ArticleCMS\ArticleCMS
Web.config path : D:\MyProject\ArticleCMS\ArticleCMS\Web.config

Backend project ''s path is D:\MyProject\ArticleCMS\ArticleManage
Web.config path: D:\MyProject\ArticleCMS\ArticleManage\Web.config

and the database file ''s path is D:\MyProject\ArticleCMS\ArticleCMS\App_Data\ArticleCMS.mdf

In my frontend project Web.config ,the connectionStrings

<connectionStrings>
    <add name="ArticleCMSEntities" connectionString="metadata=res://*/Models.ArticleCMS.csdl|res://*/Models.ArticleCMS.ssdl|res://*/Models.ArticleCMS.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\ArticleCMS.mdf;integrated security=True;connect timeout=30;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>



在后端项目Web.config中,connectionStrings应该是什么?

thx for help



In the backend project Web.config, the connectionStrings should be what?

thx for help

推荐答案

如果要连接到同一个数据库,则是IMO,应该使用相同的连接字符串.连接字符串本身应该没有任何区别.

值得一提的是,前端项目实际上不应与数据库进行通信.它应该与后端项目通信,而后端项目又应该连接到数据库.
If you are connecting to the same database, then IMO, you should be using the same connection string. There should really be no difference in the connection strings themselves.

Just on another note, the frontend project should not really be communicating with the database. It should be communicating with the backend project, which in turn should be connecting to the database.


这篇关于两个项目使用一个数据库文件,如何在两个项目中配置connectionStrings?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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