简体   繁体   中英

LinqToSql and Entity Framework or ADO.Net?

I was using ADO.Net in my .Net projects from the past few years. Now I started using Linq2Sql and Entity Framework.

When using ADO.Net application my client should have SQL Server in their system to access the database file.

But some one has told me that Linq2Sql and Entity Framework doesn't need SQL Server on the client, it just need the .mdf file to access the database.

Because in LinqToSql we give the connection as the path of .mdf file

DataContext dc= new DataContext("path to database file");

Is it true?

Please explain me all the things.

I highly doubt that you can directly use ,mdf file without SQL Server because

  1. Database transactions are not simply file reading and writing that can be done directly against .mdf file.

  2. LINQ to SQL queries are first converted into SQL and then executed. Without SQL Server engine, how these SQL queries would be interpreted

It is not related with ADO.net or LINQ2SQL or EntityFramework. It is related with which Database Edition you are using. And I don't think you can use .mdf file without Installing SQL Database Server from any of above data access technology.

May be you are referring to SQL Compact Edition ( .sdf ). Which you can use without installing SQL Server. (You can also connect with ADO.net to .sdf database file)

myConnection = new SqlCeConnection("Data Source=\\Mobile\\Northwind.sdf;");
myConnection.Open();

[SQL Compact Edition]

You're thinking User Instances , replaced by LocalDB in SQL Server 2012. This has nothing to do specifically with Linq to SQL or Entity Framework. And all these options require installing SQL Server on the client machine.

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