Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hard code Entity Framework connection string

When I add an Entity Framework Model to a class library, it creates an app.config file where the connection string is stored.

What do I have to do, to bake the connection string into the project output (*.dll)?

like image 488
Kuckucksei Avatar asked Apr 23 '26 13:04

Kuckucksei


1 Answers

Store it in a constant or compute it in a variable dbConnect, then pass into the constructor.

MyDatabaseEntities = new MyDatabaseEntities(dbConnect);
like image 198
agent-j Avatar answered Apr 26 '26 03:04

agent-j



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!