Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No connection string with key '' in configuration file! #3218

Closed
ademc opened this issue Feb 6, 2018 · 5 comments
Closed

No connection string with key '' in configuration file! #3218

ademc opened this issue Feb 6, 2018 · 5 comments

Comments

@ademc
Copy link

ademc commented Feb 6, 2018

I have add a connection string into web.config.

<connectionStrings> <add name="Snapshot" connectionString="Server=94.94.94.94;Database=db;Uid=use5;Pwd=ppppp;CHARSET=utf8;convert zero datetime=True" providerName="MySql.Data.MySqlClient" /> </connectionStrings>

I used this connectionString for my row with ConnectionKey attribute but endpoint connections executed with Default.

And I want to check
for testing purpose

I have add this piece of code in SiteInitialization.ApplicationStart

public static void ApplicationStart() { try { SqlConnections.GetConnectionString("Snapshot").Dialect = SqlServer2005Dialect.Instance;

I got this error: No connection string with key Snapshot in configuration file!

This is simple serene project, no advanced modification. Why i am getting this error?

@WasimAhmad
Copy link

where should a connection string with the name of Default. as the default configuration of serenity.

@ademc
Copy link
Author

ademc commented Feb 7, 2018

I have removed default connection string from my first post. Here is complete version:

<connectionStrings> <add name="Default" connectionString="Data Source=(LocalDb)\MSSqlLocalDB; Initial Catalog=Project1_Default_v1; Integrated Security=True" providerName="System.Data.SqlClient"/> <add name="Snapshot" connectionString="Server=94.94.94.94;Database=db;Uid=use5;Pwd=ppppp;CHARSET=utf8;convert zero datetime=True" providerName="MySql.Data.MySqlClient" /> </connectionStrings>

@volkanceylan
Copy link
Member

You need to write line after CommonInitialization.Run as configuration subsystem is not initialized yet

@volkanceylan
Copy link
Member

Serenity.Web.CommonInitialization.Run();
SqlConnections.GetConnectionString("Snapshot").Dialect = SqlServer2005Dialect.Instance

@ademc
Copy link
Author

ademc commented Feb 7, 2018

I got it. I have take this example from https://volkanceylan.gitbooks.io/serenity-guide/setting-connection-dialect.html
I guess little edit reqiured.
Thanks

@ademc ademc closed this as completed Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants