GetConnectionString returns null

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
entwicklungsensis
Posts: 5
Joined: Tue 21 Aug 2018 09:47

GetConnectionString returns null

Post by entwicklungsensis » Thu 06 Sep 2018 07:58

I'm using "Use the connection string from appsettings.json" option in Model settings because i dont want to insert the licence key after every generation.
But after simple generation of DBContext
optionsBuilder.UseOracle(GetConnectionString("npsModelConnectionString"));
returns "null".
It's a simple new solution after generating. No source edited. Just generated and started.

How can i solve this?

Regards
Thomas

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: GetConnectionString returns null

Post by Pinturiccio » Fri 07 Sep 2018 13:54

You can perform the following actions:
1. Open the diagram view of your model and right-click empty space. Then, on the shortcut menu, click Model Settings: http://prntscr.com/krpmr8
2. Select the "Rewrite connection string during regeneration" check box: http://prntscr.com/krpnvh
3. Click OK and rebuild you project. The appsettings.json file is created and now this code won't return null.
4. Open the diagram view of your model and right-click empty space. Then, on the shortcut menu, click Model Settings and clear the "Rewrite connection string during regeneration" check box.
This is necessary in order to avoid overwriting the file after every generation.
5. Your license key is available as a multiline text. Since JSON does not support multiline text values, you need to copy the key to any text editor and make it single-line. Replace all linebreaks with '\n' (without quotes). Then open the appsettings.json file and add the License Key to your connection string.
6. Rebuild your project. Now you will have the license key in your connection string, and it won't be overwritten after every generation.

Please notify us whether this scenario works for you.

Post Reply