Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to properly modify the data model and update sqlite db in .NET 9 in blazor web app?

$
0
0

My issue is somewhat related to these question threads (but not applicable due to being outdated and with a different overall context):


In VS Code using C# Blazor web app (.NET 9.0), more specifically, my error messages are as follows:

My thought process is by right-clicking the {MyBlazorWebAppName} project file ({MyBlazorWebAppName}.csproj) and selecting Open in Integrated Terminal, as I believe I need to update the database with my changes to the data model. However, after executing the command:

{my_project}MyBlazorWebAppName\MyBlazorWebAppName> dotnet ef database update

I got this build failed message:

Build started...
Build failed. Use dotnet build to see the errors.

Moreover, by executing: dotnet build or Ctrl+Shift+P> .NET: Build, I got these error message:

error CS1061: 'Admin' does not contain a definition for 'FullName' andno accessible extension method 'FullName' accepting a first argumentof type 'Admin' could be found (are you missing a using directive oran assembly reference?)


What I've done before encountering those errors:

In my Models/Admin.cs:

Old data model:

using System.ComponentModel.DataAnnotations;namespace GlamGearAdmin.Models;public class Admin{    [Key]    public string? UserID { get; set; }    public string? Username { get; set; }    public string? FullName { get; set; }    public string? EmailAdd { get; set; }    public string? RoleType { get; set; }}

With changes applied:

using System.ComponentModel.DataAnnotations;namespace GlamGearAdmin.Models;public class Admin{    [Key]    public string? UserID { get; set; }    public string? Username { get; set; }    public string? GivenName { get; set; }    public string? MiddleName { get; set; }    public string? FamilyName { get; set; }    public string? EmailAdd { get; set; }    public string? RoleType { get; set; }}

As you may have noticed, I replaced FullName with GivenName, MiddleName, and FamilyName.

I’m uncertain how to apply my data model changes to my SQLite database.

Note: I've followed and completed the tutorial for this particular section: Build a Blazor movie database app (Part 2 - Add and scaffold a model)


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>