tzu
tzu

Reputation: 1

Configuration for Database Connection

Please I'm new to C# and I've been trying to configure my code to work with a database. I need a proper and step by step guide on how to go about it. Thanks

I have created a class that inherits from Dbcontext and also configured it in program.cs but when I opened package manager console and typed in "add-migration AddRazortoDb" (Razor is my project name) the error report is " Unable to create an object of type 'AppDbContext'

Upvotes: 0

Views: 353

Answers (1)

Sudharsan R
Sudharsan R

Reputation: 19

nuget packages : ef server,ef tool,ef core
connection string for sql server :

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(@"server=DESKTOP-CV0FSTJ\SQLEXPRESS;database=DBName;trusted_connection=true;"); }

Upvotes: 0

Related Questions