Ahmadali Shafiee
Ahmadali Shafiee

Reputation: 4657

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?

P.S.

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

P.S. 2

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

Upvotes: 0

Views: 247

Answers (1)

Saravanan
Saravanan

Reputation: 7854

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

Upvotes: 1

Related Questions