

In the configuration file, we can now keep more than one string and also tell which database for each connection. The second way is to keep the string out of the executable, so that you can modify it at any time, in this case we will use the application's configuration file ( app.config or web.config): In the example below, CompanyDb is the name of the connection string. In the appsettings.json file, add the connection string for the SQL database. Use NuGet Package Manager to install in the project. However, although youre trying it with Firebird, as mentioned, you have to use a different connection string. Option 2: Specify the connection in the configuration file Install Entity Framework Core SQL Server provider. Manually run SQL scripts generated by Entity Framework Core in your apps database.

In this case, the EFExample database will be created on the local SQL server. Configure your connection string string appropriately, for example. This is quite convenient if you need to display or log the connection string used for your current DbContext for some reason or if you somehow form your DbContext objects dynamically, and need to. This article describes how to access and extract the connection strings from your Entity Framework (Core) database context objects. If your connection string contains sensitive information, such as username and password, you can protect the contents of the configuration file using Protected Configuration. This post was most recently updated on February 26th, 2021. ContextExample ctx = new ContextExample( "data source=(local) initial catalog=EFExample user id=test password=test ") The connection string should be added to your application's App.config file (Web.config if you are using ASP.NET).
