Your expertise is greatly needed, please advise on using connection string in .NET with multiple project.
In .NET Core there is no configuration file, I have a project with all my contract (Interfaces) I need to access the database or create a connection to the databasehow do I accomplish creating a database connection?
Solution Structure - This solution has three project and DBEntity provides database connection, help we with accessing the database or setup file from a different project?
- WebProjectApp (in this project I have the controllers, view, models and appsettings.json, appsettings.json and so on....)
- WebAppServices (in this project I have all my contracts (interface and it instantiate database access from DBEntityConn...)
- DBEntityConn (project is where need to create a connection to the database, as before I could use leverage the web.config file. In .NET Core there is not web.config.)
How to I make the database connection or access the setup.cs file?
Example of codes in DBEntityConn AppEntity.cs
public AppEntity(DbContextOptions<AppEntity> options)
: base(options)
{
}
public AppEntity()
: base()
{
}
An example of the OLD way with web.config file, how do I make this same code work above?
public AppEntity(DbContextOptions<AppEntity> options)
: base("name=ConnectionString")
{
}