Empty DbProviderFactories in .net-core application and mashine.config(s)












0















I'm noticed the code



`DataTable table = DbProviderFactories.GetFactoryClasses();` 


works different in applications targeted as .NET Framework 4.x and .NET Core 2.x.
For the former application I receive the providers list with 4 items and for the latter one the list is empty.



I have read about similar issues and figured out the providers list is stored in mashine.config file (I have console applications, so I haven't web.config and have only one app.config file which is almost empty). So I assume my problem is linked with mashine.config file(s).



I have found 6 mashine.config files on my desktop.




c:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFramework64v2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config
c:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config
c:Windowswinsxsamd64_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_81fa0191bdd08961machine.config
c:Windowswinsxsx86_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_c9a73868d24cb267machine.config




Files from folders v2.0.50727 and winsxs have the "full" section



   <system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</DbProviderFactories>
</system.data>


but files from v4.0.30319 have the empty one:



<system.data>
<DbProviderFactories/>
</system.data>


I can see it on two PCs, so I don't think my Windows or NET installations are corrupted.



So now here are my questions:




  1. Am I right in .NET Core 2.x application gets DbProviderFactories list from mashine.config file located in v4.0.30319 folder?

  2. Why this list is empty? I mean, what software is responsible for its filling? Do I need to install/add/restore something?

  3. Is it safe to add providers list in this file manually (just to copy from "full-list" file)?


Thanks.










share|improve this question























  • .NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

    – Grzesiek Danowski
    Nov 16 '18 at 10:53











  • @GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

    – Miamy
    Nov 16 '18 at 11:09






  • 1





    Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

    – Grzesiek Danowski
    Nov 16 '18 at 11:26











  • @GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

    – Miamy
    Nov 16 '18 at 11:39
















0















I'm noticed the code



`DataTable table = DbProviderFactories.GetFactoryClasses();` 


works different in applications targeted as .NET Framework 4.x and .NET Core 2.x.
For the former application I receive the providers list with 4 items and for the latter one the list is empty.



I have read about similar issues and figured out the providers list is stored in mashine.config file (I have console applications, so I haven't web.config and have only one app.config file which is almost empty). So I assume my problem is linked with mashine.config file(s).



I have found 6 mashine.config files on my desktop.




c:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFramework64v2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config
c:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config
c:Windowswinsxsamd64_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_81fa0191bdd08961machine.config
c:Windowswinsxsx86_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_c9a73868d24cb267machine.config




Files from folders v2.0.50727 and winsxs have the "full" section



   <system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</DbProviderFactories>
</system.data>


but files from v4.0.30319 have the empty one:



<system.data>
<DbProviderFactories/>
</system.data>


I can see it on two PCs, so I don't think my Windows or NET installations are corrupted.



So now here are my questions:




  1. Am I right in .NET Core 2.x application gets DbProviderFactories list from mashine.config file located in v4.0.30319 folder?

  2. Why this list is empty? I mean, what software is responsible for its filling? Do I need to install/add/restore something?

  3. Is it safe to add providers list in this file manually (just to copy from "full-list" file)?


Thanks.










share|improve this question























  • .NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

    – Grzesiek Danowski
    Nov 16 '18 at 10:53











  • @GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

    – Miamy
    Nov 16 '18 at 11:09






  • 1





    Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

    – Grzesiek Danowski
    Nov 16 '18 at 11:26











  • @GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

    – Miamy
    Nov 16 '18 at 11:39














0












0








0








I'm noticed the code



`DataTable table = DbProviderFactories.GetFactoryClasses();` 


works different in applications targeted as .NET Framework 4.x and .NET Core 2.x.
For the former application I receive the providers list with 4 items and for the latter one the list is empty.



I have read about similar issues and figured out the providers list is stored in mashine.config file (I have console applications, so I haven't web.config and have only one app.config file which is almost empty). So I assume my problem is linked with mashine.config file(s).



I have found 6 mashine.config files on my desktop.




c:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFramework64v2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config
c:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config
c:Windowswinsxsamd64_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_81fa0191bdd08961machine.config
c:Windowswinsxsx86_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_c9a73868d24cb267machine.config




Files from folders v2.0.50727 and winsxs have the "full" section



   <system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</DbProviderFactories>
</system.data>


but files from v4.0.30319 have the empty one:



<system.data>
<DbProviderFactories/>
</system.data>


I can see it on two PCs, so I don't think my Windows or NET installations are corrupted.



So now here are my questions:




  1. Am I right in .NET Core 2.x application gets DbProviderFactories list from mashine.config file located in v4.0.30319 folder?

  2. Why this list is empty? I mean, what software is responsible for its filling? Do I need to install/add/restore something?

  3. Is it safe to add providers list in this file manually (just to copy from "full-list" file)?


Thanks.










share|improve this question














I'm noticed the code



`DataTable table = DbProviderFactories.GetFactoryClasses();` 


works different in applications targeted as .NET Framework 4.x and .NET Core 2.x.
For the former application I receive the providers list with 4 items and for the latter one the list is empty.



I have read about similar issues and figured out the providers list is stored in mashine.config file (I have console applications, so I haven't web.config and have only one app.config file which is almost empty). So I assume my problem is linked with mashine.config file(s).



I have found 6 mashine.config files on my desktop.




c:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFramework64v2.0.50727CONFIGmachine.config
c:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config
c:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config
c:Windowswinsxsamd64_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_81fa0191bdd08961machine.config
c:Windowswinsxsx86_netfx-machine_config_ocm_b03f5f7f11d50a3a_6.1.7601.17514_none_c9a73868d24cb267machine.config




Files from folders v2.0.50727 and winsxs have the "full" section



   <system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</DbProviderFactories>
</system.data>


but files from v4.0.30319 have the empty one:



<system.data>
<DbProviderFactories/>
</system.data>


I can see it on two PCs, so I don't think my Windows or NET installations are corrupted.



So now here are my questions:




  1. Am I right in .NET Core 2.x application gets DbProviderFactories list from mashine.config file located in v4.0.30319 folder?

  2. Why this list is empty? I mean, what software is responsible for its filling? Do I need to install/add/restore something?

  3. Is it safe to add providers list in this file manually (just to copy from "full-list" file)?


Thanks.







c# .net-core






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 10:49









MiamyMiamy

1,119817




1,119817













  • .NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

    – Grzesiek Danowski
    Nov 16 '18 at 10:53











  • @GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

    – Miamy
    Nov 16 '18 at 11:09






  • 1





    Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

    – Grzesiek Danowski
    Nov 16 '18 at 11:26











  • @GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

    – Miamy
    Nov 16 '18 at 11:39



















  • .NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

    – Grzesiek Danowski
    Nov 16 '18 at 10:53











  • @GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

    – Miamy
    Nov 16 '18 at 11:09






  • 1





    Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

    – Grzesiek Danowski
    Nov 16 '18 at 11:26











  • @GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

    – Miamy
    Nov 16 '18 at 11:39

















.NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

– Grzesiek Danowski
Nov 16 '18 at 10:53





.NET Core is light framework that not use GAC and therefore you can install globally DbProviders. You should install them for every your application. Or use full Framework.

– Grzesiek Danowski
Nov 16 '18 at 10:53













@GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

– Miamy
Nov 16 '18 at 11:09





@GrzesiekDanowski, excuse me, but I don't understand how to install DbProviders for the application. I have references to Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer packages in my .csproj file, but it isn't to be enough...

– Miamy
Nov 16 '18 at 11:09




1




1





Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

– Grzesiek Danowski
Nov 16 '18 at 11:26





Interesting article: weblog.west-wind.com/posts/2017/Nov/27/…

– Grzesiek Danowski
Nov 16 '18 at 11:26













@GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

– Miamy
Nov 16 '18 at 11:39





@GrzesiekDanowski, thank you! It seems this guy knows what to do with my problem :)

– Miamy
Nov 16 '18 at 11:39












1 Answer
1






active

oldest

votes


















0














I decide to post the answer because this topic really was not clear to me and I hope I can help anyone to avoid my mistakes.



EF Core is slightly different from EF5/6 I was used before. There is no visual designer for database<->model operations here. There is no early-known DB providers too.



With EF Core we can build a model based on existing database in VS Package Manager Console (ok, we can use dotnet CLI too, but as for me it's easier to use the former one). And we need to add a required DB provider via NuGet Manager.



I fond the pretty tutorial here: http://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx.



Also, here there is a good article how someone can implement DbProviderFactory dynamic loading (it's was a starting point of my question).






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336341%2fempty-dbproviderfactories-in-net-core-application-and-mashine-configs%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I decide to post the answer because this topic really was not clear to me and I hope I can help anyone to avoid my mistakes.



    EF Core is slightly different from EF5/6 I was used before. There is no visual designer for database<->model operations here. There is no early-known DB providers too.



    With EF Core we can build a model based on existing database in VS Package Manager Console (ok, we can use dotnet CLI too, but as for me it's easier to use the former one). And we need to add a required DB provider via NuGet Manager.



    I fond the pretty tutorial here: http://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx.



    Also, here there is a good article how someone can implement DbProviderFactory dynamic loading (it's was a starting point of my question).






    share|improve this answer




























      0














      I decide to post the answer because this topic really was not clear to me and I hope I can help anyone to avoid my mistakes.



      EF Core is slightly different from EF5/6 I was used before. There is no visual designer for database<->model operations here. There is no early-known DB providers too.



      With EF Core we can build a model based on existing database in VS Package Manager Console (ok, we can use dotnet CLI too, but as for me it's easier to use the former one). And we need to add a required DB provider via NuGet Manager.



      I fond the pretty tutorial here: http://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx.



      Also, here there is a good article how someone can implement DbProviderFactory dynamic loading (it's was a starting point of my question).






      share|improve this answer


























        0












        0








        0







        I decide to post the answer because this topic really was not clear to me and I hope I can help anyone to avoid my mistakes.



        EF Core is slightly different from EF5/6 I was used before. There is no visual designer for database<->model operations here. There is no early-known DB providers too.



        With EF Core we can build a model based on existing database in VS Package Manager Console (ok, we can use dotnet CLI too, but as for me it's easier to use the former one). And we need to add a required DB provider via NuGet Manager.



        I fond the pretty tutorial here: http://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx.



        Also, here there is a good article how someone can implement DbProviderFactory dynamic loading (it's was a starting point of my question).






        share|improve this answer













        I decide to post the answer because this topic really was not clear to me and I hope I can help anyone to avoid my mistakes.



        EF Core is slightly different from EF5/6 I was used before. There is no visual designer for database<->model operations here. There is no early-known DB providers too.



        With EF Core we can build a model based on existing database in VS Package Manager Console (ok, we can use dotnet CLI too, but as for me it's easier to use the former one). And we need to add a required DB provider via NuGet Manager.



        I fond the pretty tutorial here: http://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx.



        Also, here there is a good article how someone can implement DbProviderFactory dynamic loading (it's was a starting point of my question).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 10:36









        MiamyMiamy

        1,119817




        1,119817
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336341%2fempty-dbproviderfactories-in-net-core-application-and-mashine-configs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly