简体   繁体   中英

How to use LINQ for standard C# application with local database file?

I'm used to work with ASP.NET and I have no problems there, but now I need to create a C# Console application and something is wrong.

  • I create console application
  • Add new item to project (Local database)
  • Fill in some basic data (id, name)

But when I create LINQ to SQL Class and drag my table to it like I do in ASP.NET I get error

The selected objects use an unsupported data provider

What am I doing wrong here, how can I make my work with databases using C# Console/Windows application as fast and easy as with ASP.NET applications?

The database driver / provider needs to allow for the usage of linq. If you are using a simple sqlite db, I would recommend using the DBLinq provider .

If you are using Microsoft's lightweight database (Sql Compact) then I believe this article maybe helpful.

The Object Relational Designer (O/R Designer) supports only the .NET Framework Data Provider for SQL Server ( System.Data.SqlClient).

Where as sdf local DB is a Compact Database. SQL Server Compact Edition (System.Data.SqlServerCe) is not supported by O/R Designer.

Instead you can create a db in SQLExpress and connect to Designer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM