Closed VigneashSelvaraj closed 11 months ago
It can, provided you use the correct underlying driver. When and where do you se this? In which VS version using which DDEX provider?
Mine is a web app (.NET Framework 4.6) hosted on Azure app service which connects Azure SQL server via SQL authentication (username/password) using Entity Framework inheriting from DbContext class from System.Data.Entity namespace.
I’m planning to use Active Directory Service Principal authentication mode. Due to this I modified my connection string like “Data Source= servername.database.windows.net; Encrypt=True; Initial Catalog= dbname; Authentication=Active Directory Service Principal; User Id=servicePrincipalID; Password=servicePrincipalPassword;”
Modified string throws System.ArgumentException: 'Invalid value for key 'authentication'.' error when trying to open the connection. Many online articles/resources have clear integration for .Net core apps using Microsoft.EntityFrameworkCore assembly, however nothing much for .Net Framework app.
from the above readme file, does the DbContext class comes from System.Data.Entity namespace ?
Yes
Below is my app db context class using System; using System.Data.Entity; using System.Data.Entity.SqlServer;
namespace SampleApp.Databases { [DbConfigurationType(typeof(MicrosoftSqlDbConfiguration))] public class SampleAppContext : DbContext, IDisposable, IContentValidationContext { public SampleAppContext(string connectionString) : base(connectionString) {
}
Error I see:
System.ArgumentException
HResult=0x80070057
Message=Invalid value for key 'authentication'.
Source=
and the connection string is “Data Source= servername.database.windows.net; Encrypt=True; Initial Catalog= dbname; Authentication=Active Directory Service Principal; User Id=servicePrincipalID; Password=servicePrincipalPassword;”
Please share a full repro if you want free support. Do you get this error locally or on your app service?
This happens in my local.
Maybe duplicate of https://github.com/ErikEJ/EntityFramework6PowerTools/issues/129 - otherwise share a full repro project.
Could you please review https://github.com/VigneashSelvaraj/SqlServerAuthFramework/tree/master
@VigneashSelvaraj Thanks, please share some repro steps.
Why are you not using .NET ??
Use this config! That is why it is important to share all details!
<connectionStrings>
<add
name="SqlConnectionString"
connectionString="Data Source=servrename.database.windows.net;Encrypt=True;Initial Catalog=dbname;Authentication=Active Directory Service Principal;User Id=userid;Password=password;"
providerName="Microsoft.Data.SqlClient" />
</connectionStrings>
thanks, it worked
You are welcome
If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship
Hi @ErikEJ
In my web app, I do have a Business logic project holding Dbcontext. Can I just install ErikEJ.EntityFramework.SqlServer package in Business logic project alone ? (or) do I have to install the same package in that web project calling BL project ?
@VigneashSelvaraj What have you tried? Also, this issue is closed.
Hi - when I use Authentication key in my SQL connection string, I see above error. Can EF not process non sql auth ?