dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.39k stars 975 forks source link

Dataset is using System.Data.SqlClient.SqlDataAdapter not Microsoft.Data.SqlClient #8534

Open reader-man opened 1 year ago

reader-man commented 1 year ago

Environment

VisualStudio.17.Release/17.4.4+33213.308 Microsoft .NET Framework Version 4.8.04084

.NET version

4.8

Did this work in a previous version of Visual Studio and/or previous .NET release?

no

Issue description

i am trying to move from "System.Data.SqlClient" to "Microsoft.Data.SqlClient", and all my code is working, but when i change the dataset autogenerated code to use the new "Microsoft.Data.SqlClient.SqlDataAdapter" it works, but when adding any new tables or changing the fields in the dataset designer, it returns the "SqlDataAdapter" to use: "System.Data.SqlClient.SqlDataAdapter" so how to make the designer stay using the new "Microsoft.Data.SqlClient.SqlDataAdapter". and this is also happening to: private global::System.Data.SqlClient.SqlDataAdapter _adapter; private global::System.Data.SqlClient.SqlConnection _connection; private global::System.Data.SqlClient.SqlTransaction _transaction; private global::System.Data.SqlClient.SqlCommand[] _commandCollection;

e.g.: namespace MetaObjectDAL.DS_FormsTableAdapters {

/// <summary>
///Represents the connection and commands used to retrieve and save data.
///</summary>
[global::System.ComponentModel.DesignerCategoryAttribute("code")]
[global::System.ComponentModel.ToolboxItem(true)]
[global::System.ComponentModel.DataObjectAttribute(true)]
[global::System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner" +
    ", Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
public partial class MetaObjectTableAdapter : global::System.ComponentModel.Component {

    private global::System.Data.SqlClient.SqlDataAdapter _adapter;

    private global::System.Data.SqlClient.SqlConnection _connection;

    private global::System.Data.SqlClient.SqlTransaction _transaction;

    private global::System.Data.SqlClient.SqlCommand[] _commandCollection;

Steps to reproduce

create a new winforms solution add a dataset from sql server tables. the compile it. then add nuget "Microsoft.Data.SqlClient" and replace all references of "Microsoft.Data.SqlClient" to "System.Data.SqlClient" save and re-compile.

then open the dataset in designer mode, and add to it a new table from sql server. save it. go to the Dataset code, and u will see that it returned to the old: "System.Data.SqlClient"

Diagnostics

No response

elachlan commented 1 year ago

Are you trying this in .NET 6/7? Issues with .NET 4.8 are supposed to be reported via visual studio.

reader-man commented 1 year ago

thanks u are right, this should go for VS.