<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Cannot create data source on gateway - PowerBIEntityFrameworkOperationException in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-create-data-source-on-gateway/m-p/1534874#M26692</link>
    <description>&lt;P&gt;I am trying to create a new data source on a gateway using the .NET SDK, but every call results in bad request due to a PowerBIEntityFrameworkOperationException.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to follow the instructions on&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3#configure-a-new-data-source-for-a-data-gateway" target="_self"&gt;https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3#configure-a-new-data-source-for-a-data-gateway&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but I may have missed something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string oleConnectionString = "{\"connectionString\":\"provider=SQLOLEDB.1;initial catalog=my database;data source=my server;ApplicationIntent=ReadOnly\"}";
var credentialsEncryptor = new AsymmetricKeyEncryptor(gateway.PublicKey);

var credentials = new BasicCredentials("my username", "my password");
var credentialDetails = new CredentialDetails(credentials, PrivacyLevel.Organizational, EncryptedConnection.Encrypted, credentialsEncryptor);
var oleRequest = new PublishDatasourceToGatewayRequest("OleDb", oleConnectionString, credentialDetails, "New data source");

var newDatasource = await pbi.Gateways.CreateDatasourceAsync(gateway.Id, oleRequest);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Creating the data source manually in the Power BI portal. This works.&lt;/P&gt;&lt;P&gt;2. My data source is SQL Server but I need to pass parameters in the connection string so I'm using the OleDB provider. As a test I've tried change the data source type to "SQL" and the connection details to&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"{\"server\":\"my server\",\"database\":\"my database\"}". This results in the same&amp;nbsp;PowerBIEntityFrameworkOperationException exception.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3. I've tried calling the UpdateDatasource method to change the credentials on a manually created data source. This worked, which&amp;nbsp; suggests that I'm passing the credentials correctly.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sun, 06 Dec 2020 18:29:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-12-06T18:29:19Z</dc:date>
    <item>
      <title>Cannot create data source on gateway - PowerBIEntityFrameworkOperationException</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-create-data-source-on-gateway/m-p/1534874#M26692</link>
      <description>&lt;P&gt;I am trying to create a new data source on a gateway using the .NET SDK, but every call results in bad request due to a PowerBIEntityFrameworkOperationException.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to follow the instructions on&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3#configure-a-new-data-source-for-a-data-gateway" target="_self"&gt;https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3#configure-a-new-data-source-for-a-data-gateway&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but I may have missed something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string oleConnectionString = "{\"connectionString\":\"provider=SQLOLEDB.1;initial catalog=my database;data source=my server;ApplicationIntent=ReadOnly\"}";
var credentialsEncryptor = new AsymmetricKeyEncryptor(gateway.PublicKey);

var credentials = new BasicCredentials("my username", "my password");
var credentialDetails = new CredentialDetails(credentials, PrivacyLevel.Organizational, EncryptedConnection.Encrypted, credentialsEncryptor);
var oleRequest = new PublishDatasourceToGatewayRequest("OleDb", oleConnectionString, credentialDetails, "New data source");

var newDatasource = await pbi.Gateways.CreateDatasourceAsync(gateway.Id, oleRequest);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Creating the data source manually in the Power BI portal. This works.&lt;/P&gt;&lt;P&gt;2. My data source is SQL Server but I need to pass parameters in the connection string so I'm using the OleDB provider. As a test I've tried change the data source type to "SQL" and the connection details to&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"{\"server\":\"my server\",\"database\":\"my database\"}". This results in the same&amp;nbsp;PowerBIEntityFrameworkOperationException exception.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3. I've tried calling the UpdateDatasource method to change the credentials on a manually created data source. This worked, which&amp;nbsp; suggests that I'm passing the credentials correctly.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 06 Dec 2020 18:29:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-create-data-source-on-gateway/m-p/1534874#M26692</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-06T18:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create data source on gateway - PowerBIEntityFrameworkOperationException</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-create-data-source-on-gateway/m-p/1583618#M27062</link>
      <description>&lt;P&gt;I'm receiving the same error. Also trying it in the sandbox (&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource" target="_blank"&gt;https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource&lt;/A&gt;) returns the same error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 06:54:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-create-data-source-on-gateway/m-p/1583618#M27062</guid>
      <dc:creator>jpu</dc:creator>
      <dc:date>2021-01-06T06:54:31Z</dc:date>
    </item>
  </channel>
</rss>

