Skip to content

Move database configuration to config file instead of hardcoding #3

@StefH

Description

@StefH

Use:

services.AddDbContext<MyHotelDbContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:MyHotelDb"]));

And define appsettings .Development.json like:

"ConnectionStrings": {
    "MyHotelDb": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MyHoteDbl;Trusted_Connection=True;MultipleActiveResultSets=true"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions