I've been trying to follow this tutorial for a multiple image uploader:
https://youtu.be/sLYL_IZYnjw?t=244
It seems that at some point the template for a Blazor project combined Startup.cs and Program.cs into Program.cs.
The tutorial wants me to add this code to Program.cs:
<pre lang="C#"><pre>public IConfiguration Configuration { get; }
var cs = Configuration.GetConnectionString("FileUploadDbContext");
AsyncServiceScope.AddDbContext<FileUploadDbContext>(option => option.UseSqlServer(cs));
However I get the following errors:
Error CS0116 A namespace cannot directly contain members such as fields, methods or statements MultipleFileUpload C:\Users\will.sewell\source\repos\MultipleFileUpload\MultipleFileUpload\Program.cs 15 Active
Error CS0103 The name 'Configuration' does not exist in the current context MultipleFileUpload C:\Users\will.sewell\source\repos\MultipleFileUpload\MultipleFileUpload\Program.cs 17 Active
Error CS0117 'AsyncServiceScope' does not contain a definition for 'AddDbContext' MultipleFileUpload C:\Users\will.sewell\source\repos\MultipleFileUpload\MultipleFileUpload\Program.cs 19 Active
What I have tried:
I've tried adding a namespace to Program.cs but don't think that's what I should be doing.
I've tried IConfiguration.GetConnectionString instead of Configuration.GetConnectionString and i've also tried it as System.Configuration.
Also I can't seem to add links correctly. If you copy the link out it works but if you just click on it, it comes back to this question.
Any help/ advice would be appreciated.