Azure AD Authentication for Entity Framework 6 in DB first approach

Admin - Priti Prakash Jagtap 1 Reputation point
2020-12-15T04:13:53.253+00:00

Trying to configure the connection string to use Azure AD Authentication. I am able to connect to SQL Server using standard SQL Connection with Azure AD Authentication. My application uses Entity Framework 6 DataBase first approach. I have override the DbContext to generate the connection string at run time. Is it possible to configure the Azure AD AUthentication for EF 6 Data Base First approach.

I am getting keyword metadata not supported when trying to connect with standard SQL connection as my model is build using Database first approach. If am removing metadata from connection string then am getting Untintional Code First exception.

How can I configure EF 6 DataBase first approach with Azure AD Authentication

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,606 Reputation points
    2020-12-15T06:27:12.93+00:00

    Hi @Admin - Priti Prakash Jagtap , welcome to Microsoft Q&A forum.

    It looks an issue with the connection string itself as you mentioned as you might be trying to use the connection string in ADO objects. Can you remove everything from connectionstring and keep the string between '&quot' as below:

    From this:

    <add name="yourdatabase" connectionString="metadata=res://*/Data.Model.AdvertisingModel.csdl|res://*/Data.Model.AdvertisingModel.ssdl|res://*/Data.Model.AdvertisingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=*****;initial catalog=****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />  
    

    To this:

    <add name="yourdatabase" connectionString="data source=*****;initial catalog=****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.EntityClient" />  
    

    Reference article:
    https://stackoverflow.com/questions/34635822/how-do-i-solve-keyword-not-supported-metadata

    Please let us know if this works or else we can discuss further.

    ----------

    If answer helps, please select 'Accept Answer' as this could help other community members looking for similar queries.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.