简体   繁体   中英

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)?

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

MyDatabaseEntities = new MyDatabaseEntities(dbConnect);

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