Besuglov Sergey
Besuglov Sergey

Reputation: 506

Entity Framework connection string connecting to file

Is there a way to build Entity Framework connection string to connect to a file-Database in a standalone c# application?

Upvotes: 2

Views: 123

Answers (2)

Edi G.
Edi G.

Reputation: 2422

Something like this ?

<add name="ConnectionName"
    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|DatabaseName.mdf;Integrated Security=True;User Instance=True"
    providerName="System.Data.SqlClient" />

Upvotes: 1

Kjartan
Kjartan

Reputation: 19101

You might take a look at Sql Express, which can be embedded directly into your application.

Quote from the page:

Do you need to embed SQL Server Express into an application? LocalDB is a lightweight version of Express that has all its programmability features yet runs in user mode and has a fast, zero-configuration installation. (...) LocalDB runs in-process with applications and not as a service.

You can download the installer from that same page.

Upvotes: 0

Related Questions