0

I'm trying to port a NET Framework 4.7.2 class library project to NET Core 3.1 (or 5.0). The project uses a database through the System.Data.Odbc Nuget package. The problem is that the Visual Studio Database Designer generates code that references OleDb and Properties (global::...Settings) that cause reference errors during compilation.

Here are bits of code generated by the designer for OleDb and Properties:

public partial class ColorsTableAdapter : global::System.ComponentModel.Component {
        private global::System.Data.OleDb.OleDbDataAdapter _adapter;
        private global::System.Data.OleDb.OleDbConnection _connection;


 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")]
        private void InitConnection() {
            this._connection = new global::System.Data.Odbc.OdbcConnection();
            this._connection.ConnectionString = global::NewDatabase.Properties.Settings.Default.NewConnectionString;
        }

I am new to NET Core so maybe I have set up Properties/Settings in the project somehow? (I have not set up any connection strings, so maybe it's referencing old strings somewhere?)

But I'm using Odbc everywhere in my code, so I don't know why the Designer is generating OleDb code. I deleted the designer.cs file to force a regeneration, but the regenerated file regenerates the bad code. In the end I added the System.Data.OleDb package to make the compilation errors go away, but it doesn't make sense to me.

How can I fix the two problems? All I can think of is to delete the entire DataSet.xsd file and start over again, but that seems like a low-probability action. Thank you

Kevin
  • 1,548
  • 2
  • 19
  • 34
  • can you tell me how do you generate the code by designer? Also, please tell me how do you make the migrations about it, which can make your problem much clear. – Jack J Jun Dec 29 '20 at 02:28
  • Hi, the typed dataset code was originally generated by VS Designer on the NET Framework 4.7.2 project when I dragged and dropped tables from the Server Explorer onto the designer surface. I don't know if it is possible to use the VS Database Designer on a NET Core project. I could not define a data source when I tried it. thank you. – Kevin Dec 29 '20 at 06:42
  • In the NET 4.7.2 project, I ran into the same Properties error. The problem was in the Designer-generated code - it "lost" (or "remembered") the old Settings file info when I moved the Database .xsd files to a new project. I deleted the old .xsd set and built a new set in the new project (also defining a new DataSource), and that solved the Properties issue. I imagine when I return to the NET Core project for a second round that this method will address the issue. – Kevin Dec 29 '20 at 07:52

0 Answers0