简体   繁体   中英

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

I have these 5 projects: 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.

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.)

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

I've tried putting my connectionstring in ViewLayer->Properties->Package/Publish SQL but that doesn't work either.

PS 2

I've tried VS2013 Community and VS2015 Ultimate Preview (the earliest version)

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

The following link has options for setting the connection string outside the web config

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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