Answered by:
MVC with entity framework code first

Question
-
Hello guys!
I'm trying to publish my application to Azure, but when I publish i have to create the server and database and i let it with the default connection string, and in my project i have two connections strings, so when i run the application it only haves the logins tables, and the product (the other connect) do not appear and if i try to access goes to an error, how can I connect both? There are my connec.:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=Minha_Pintura;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="Minha_PinturaContext" connectionString="Data Source=.;Initial Catalog=Minha_Pintura;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>Can please somebody help me? :)
Sunday, March 10, 2019 5:38 PM
Answers
-
After a long search the answer was so easy that I didn't understand (maybe I wanted more complicate :))
so ... I have one database with two connections strings, note this is a mvc project with entity Framework
and code first, what do I have to do?
just publish my app in Azure, create the resource group, the plan, server and database, in server add my IP , blabla,
when it's all done in azure, just go there to your application -> application settings -> copy the connection string of your app and paste in your web config (in our project) in connectionStrings
<connectionStrings>
<add name="DefaultConnection" connectionString="put the connection from Azure"
providerName="System.Data.SqlClient" />
<add name="Other name" connectionString="put the connection from Azure"
providerName="System.Data.SqlClient" />
</connectionStrings>
You can have more than one connectionString
;)
- Proposed as answer by Mike Ubezzi (Azure)Microsoft employee Tuesday, March 12, 2019 10:19 PM
- Marked as answer by Kalyan Chanumolu-MSFTMicrosoft employee Monday, March 18, 2019 4:03 AM
Tuesday, March 12, 2019 6:15 PM
All replies
-
Hello guys!
I'm trying to publish my application to Azure, but when I publish i have to create the server and database and i let it with the default connection string, and in my project i have two connections strings, so when i run the application it only haves the logins tables, and the product (the other connect) do not appear and if i try to access goes to an error, how can I connect both? There are my connec.:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=Minha_Pintura;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="Minha_PinturaContext" connectionString="Data Source=.;Initial Catalog=Minha_Pintura;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>Can please somebody help me? :)
Good day ,
Some clarification is needed.
You speak about publish application to Azure, but Azure is a big name which include tens of services and there are several totally different option to publish application to the Azure.
For example a Web application can be publish in Virtual Machine (VM) that you build (also known as Infrastructure as a Service where you have complete control over the VM), it can be published to Azure Web Apps feature of App Service or to Azure Cloud Services (both these last options are on VM but give you less control which is "move" to the azure control). It can also be don using other services which idoesnot fit your description like Azure Function, Azure Micro-services and more...
If the following information does not solve your needs, then Please clarify which service you are using and how do you publish your app.
>> The following article gives you full example from start to end: ASP.NET MVC 5: Connect with Azure SQLServer Database. At the end of the article you have link to download the project
>> This page gives you different option on connection string to the Azure Database.
>> In general your code should look like the following:
<add name="DefaultConnection" connectionString="Server=tcp:<replacewith your server name>.database.windows.net,1433;Initial Catalog=<Database name>;Persist Security Info=False;User ID=<your_username>;Password=<your_password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30" providerName="System.Data.SqlClient" />
Ronen Ariely
[Personal Site] [Blog] [Facebook] [Linkedin]Sunday, March 10, 2019 11:27 PM -
Hello,
my application is in code first using Microsoft.AspNet.Identity.EntityFramework;
and I have two connections strings: the default and Minha_PinturaContext, the default one I use for the login tables, register, etc. The Context one is for the paintings and comments. So when I try to publish like a simple app service, with a resource group, a server and a database i get to a point that appears a text box with the connection string created by Azure, if I leave it when I publish after create I can login but I cant use the paintings link and comments link, because they were in a different connection string, and I don't know how to fix it, the application only got the login and so on of that tables. There is no painting table or comment table.
Monday, March 11, 2019 12:13 AM -
After a long search the answer was so easy that I didn't understand (maybe I wanted more complicate :))
so ... I have one database with two connections strings, note this is a mvc project with entity Framework
and code first, what do I have to do?
just publish my app in Azure, create the resource group, the plan, server and database, in server add my IP , blabla,
when it's all done in azure, just go there to your application -> application settings -> copy the connection string of your app and paste in your web config (in our project) in connectionStrings
<connectionStrings>
<add name="DefaultConnection" connectionString="put the connection from Azure"
providerName="System.Data.SqlClient" />
<add name="Other name" connectionString="put the connection from Azure"
providerName="System.Data.SqlClient" />
</connectionStrings>
You can have more than one connectionString
;)
- Proposed as answer by Mike Ubezzi (Azure)Microsoft employee Tuesday, March 12, 2019 10:19 PM
- Marked as answer by Kalyan Chanumolu-MSFTMicrosoft employee Monday, March 18, 2019 4:03 AM
Tuesday, March 12, 2019 6:15 PM