简体   繁体   English

如何使用单独的DbContext发布ASP.NET MVC项目

[英]How to publish a ASP.NET MVC project with separated DbContext

I have these 5 projects: DataClass, DataLayer, ServiceLayer, ViewModel, ViewLayer. 我有以下5个项目:DataClass,DataLayer,ServiceLayer,ViewModel,ViewLayer。 My ViewLayer project is a ASP.NET MVC project and it's the project that is going to be published. 我的ViewLayer项目是一个ASP.NET MVC项目,并且将要发布该项目。

My problem is Visual Studio used to detect my DbContext in datalayer and ask me for a connectionstring but recently it doesn't recognize it anymore and I'm having problem with it (I've tried to put connectionstring in my web.config file in the server but that didn't work.) 我的问题是Visual Studio用来在数据层中检测我的DbContext并询问我一个连接字符串,但最近它不再能识别它了,而我遇到了问题(我尝试将连接字符串放入我的web.config文件中服务器,但没有用。)

So the problem is the published project doesn't work since it doesn't have any connectionstring. 因此,问题在于已发布的项目由于没有任何连接字符串而无法正常工作。 How can I publish my project with specifying it's connectionstring? 如何通过指定连接字符串发布项目?

PS PS

I've tried putting my connectionstring in ViewLayer->Properties->Package/Publish SQL but that doesn't work either. 我试图将我的连接字符串放在ViewLayer-> Properties-> Package / Publish SQL中,但这也不起作用。

PS 2 PS 2

I've tried VS2013 Community and VS2015 Ultimate Preview (the earliest version) 我已经尝试了VS2013社区和VS2015 Ultimate Preview(最早的版本)

You will have to set proper config transformation and update 您将必须设置适当的配置转换和更新

See below links https://msdn.microsoft.com/en-us/library/vstudio/dd465318(v=vs.100).aspx 参见下面的链接https://msdn.microsoft.com/zh-cn/library/vstudio/dd465318(v=vs.100).aspx

The following link has options for setting the connection string outside the web config 以下链接包含用于在Web配置外部设置连接字符串的选项

http://sedodream.com/PermaLink,guid,604eadfe-46bf-4989-bac8-814e2701e52a.aspx http://sedodream.com/PermaLink,guid,604eadfe-46bf-4989-bac8-814e2701e52a.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM