Entity Framework Element Code First Azure Connection

I am using Entity Framework Code First 4.3 + Azure and am having difficulty connecting to the database. The error I get is the following (on first request):

Keyword not supported: 'server'. 

I have the following connection configured in my web.config

 <configSections> type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <connectionStrings> <add name="TestDBContext" connectionString="Server=tcp:[SUBSCR].database.windows.net,1433;Database=[MyDB];User ID=[user];Password=[pass];Trusted_Connection=False;Encrypt=True;PersistSecurityInfo=True" providerName="System.Data.EntityClient" /> </connectionStrings> 

In my DbContext implementation class, the connection string name is used:

 public class MyContext : DbContext, IMyContext { public MyContext() : base("TestDBContext") { Configuration.LazyLoadingEnabled = true; Configuration.ProxyCreationEnabled = true; } 

Can you tell what is going on?

+6
source share
6 answers

I had the same problem.

You are missing all the metadata in the connection string required by the Entity Framework. The connection string provided by SQL Azure must be inserted into the provider connection string parameter of the EF provider connection string .

<add name="MyConnectionString" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;[PUT SQL AZURE CONN STRING HERE]&quot;" providerName="System.Data.EntityClient" />

You will need to use metadata from your own project. I pulled this metadata from an EF project created from an existing database.

+5
source

I had the same problem. I decided by inserting this connection string into web.config:

 <add name="eManagerTurModelConnection" connectionString="metadata=res://*/ORM.eManagerFinanceModel.csdl|res://*/ORM.eManagerFinanceModel.ssdl|res://*/ORM.eManagerFinanceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=<server>.database.windows.net;Initial Catalog=eManagerTur;Integrated Security=False;User ID=<user>;Password=<Password>;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

And after I deleted the connection string of my site, it worked because I did not receive the connection string that I added to my web.config.

English is bad ... =)

+2
source

The provider must be providerName = "System.Data.SqlClient"

I connected to Azure from VS and then looked at the properties and set the connection string and provider name.

  <add name="context" connectionString="Data Source=myServer,myPort;Initial Catalog=myDBName;Persist Security Info=True;User ID=myUserName;Password=myPassword;" providerName="System.Data.SqlClient"/> 

Then I was able to start the update database without problems.

+2
source

I tried so hard, it can help you. maybe 1433 makes the problem, no port no? or what ?, try like this.

check this link windows azure with sql

 <add name="dbContext" connectionString="Server=tcp:xxxxxxxx.database.windows.net;Database=xxxxxxxx;User ID=xxxxxxx@xxxxxxxxx ;Password=xxxxxxxxxx;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.EntityClient" /> 
0
source

Try the following:

Data Source = tcp: YOUR-DATABASE-HERE.database.windows.net, 1433; Database = GolfRounds; User ID = YOUR-USERNAME @ YOUR-SERVER; Password = YOUR PASSWORD; Trusted_Connection = False; Encryption = True;

There is also an MSDN article at http://msdn.microsoft.com/en-us/library/windowsazure/ff951633.aspx , which may be useful.

0
source

I had a similar problem when I did not have access to metadata, in which case you need to use System.Data.SqlClient as a provider. You also need to add MultipleActiveResultSets = True to the connection string

-1
source

Source: https://habr.com/ru/post/908210/


All Articles