SQL Connection in AutoCAD 2025

SQL Connection in AutoCAD 2025

hoffmann6HP4T
Participant Participant
996 Views
4 Replies
Message 1 of 5

SQL Connection in AutoCAD 2025

hoffmann6HP4T
Participant
Participant

Hi

 

What is the usual way to connect to an SQL Database with AutoCAD 2025?

In previous versions I used LinqToSQL-Classes.

 

Now with .NET Core 8 I tried:

  • EnitityFrameWorkCore (with Reverese Engineering from EF Core Power Tools) => here I get "System.PlatformNotSupportedException"
  • ADO.NET => also System.PlatformNotSupportedException

I already added <RuntimeIdentifier>win-x64</RuntimeIdentifier>, because it was suggested in Connecting to SQL Server from AutoCAD 2025 - AutoCAD DevBlog

 

I just need a hint which is the right way to go.

0 Likes
Accepted solutions (1)
997 Views
4 Replies
Replies (4)
Message 2 of 5

Norman_Yuan
Mentor
Mentor

Which version of Microsoft.EntityFrameworkCore Nuget package did you add to your project? You should not add latest version of 9.x.x, because it is for .NET 9 or later, while AutoCAD 2025/6 uses .NET 8. That is, the if you use EntityFrameworkCore in your Acad plugin, it should ne version 8.x.x or older.

 

However, EntityFrameworkCore is meant for building enterprise business entities and being accessed via service apps for data consuming user apps (AutoCAD, in this case). At this stage of technology progress, it would be better (and a trend) to avoid direct access to the database server from an user app. The data from a data source should be exposed as a services, typically, a HTTP service, and your Acad plugin uses HTTP client to reach the data.

 

If you really want to directly get data from database server, say, your data needs are very simple and want to save the effort of building an extra service layer, and the database admin does allow you to have access directly (this kind of DB admin would hard to find these days), you want to consider use much light technologies for database server access, say, considering to use Dapper (do a online search, there are a plenty of links, samples about how easy/simple Dapper would make the database server access be).

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

Civil3DReminders
Collaborator
Collaborator

The erros sound like its not finding the DLL files. Make sure to let EntityFrameworkCore to know where the DLL is located at. By default Microsoft assumes its relative to the exe currently running. In this case it would be acad.exe and not your DLL. 

I posted one solution for SQLLite, but the solution should be similar.
https://stackoverflow.com/questions/4744293/unable-to-load-dll-sqlite3-the-specified-module-could-no...

Message 4 of 5

hoffmann6HP4T
Participant
Participant

Thank you very much.

As we are only 15 Users who write in this database and everything happens internally we will stay with the direct connection to the database.

I will try Dapper and SQL Lite and document my solution here

0 Likes
Message 5 of 5

hoffmann6HP4T
Participant
Participant
Accepted solution

I have finally found the solution for my issue.
It was a bit stupid of me, but I used the dll from the folder “project\bin\Release\” as I always used to do with .NET Framework. Here I always got the error “Microsoft.Data.SqlClient is not supported on this platform”.
With .NET Core I have to use the DLL from the folder “project5\bin\x64\Debug\net8.0-windows\win-x64\”.
This works now.
I have now implemented my project with Dapper.

0 Likes