Help with converting Blazor Entity Framework Sample App to use SQL Server instead of Sqlite

Tim Tankka 5 Reputation points

I am new to Blazor. I want to change the ASP.NET Core Blazor Server with Entity Framework Core (EF Core) Sample Application from Sqlite to SQL Server. I created the Contacts table in Sql Server based on the Contact.cs model. I modified the Program.cs to use SQL Server like this:

builder.Services.AddDbContextFactory<ContactContext>(opt => opt.UseSqlServer(@"data source=mydatasource;initial catalog=acatalog;user id=auserid;Password=thepassword;Integrated Security=False;"));

When I run the app the Contacts page loads records into the grid, but when I try to view or edit a contact, I get a null reference execption in the ConcurrencyFiled.razor.OnInitialize method.

I realize that the ContactContext.cs probably needs to be modified.

My question is: Is this something that is relatively easy to do? If so any guidance or links to documentation would be appreciated.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
721 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,492 questions
{count} votes