Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Need to change model/database table in .Net Blazor-Server-Side app

$
0
0

I am building a CRUD app from a Blazor serverside project that also has EntityFramework Power Tools integrated. The initial framework I am using is from an example that is already configured with authentication identity objects. The example has the stock WeatherForecast aboard, and now that I have tested everything with the registration, logins, CRUD functionalities, I want to use one of my tables in my remote database to integrate my own thing. I am confused as in MVC , you can go to the .edmx and do an "update model from database" to make changes to your modeling. 
In the EFPT.config.json file, it shows this entry for "Tables":
"Tables": [
{
"HasPrimaryKey": true,
"Name": "[dbo].[WeatherForecast]"

}
],

....

..where as the myprojectnameContext.cs class references "some' of the field names here:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasAnnotation("ProductVersion", "2.2.0-rtm-35687");

modelBuilder.Entity<WeatherForecast>(entity =>
{
entity.Property(e => e.Date).HasColumnType("datetime");

entity.Property(e => e.Summary).HasMaxLength(50);

entity.Property(e => e.UserName).HasMaxLength(50);
});

OnModelCreatingPartial(modelBuilder);
}


.... , but it's not all the fields for the WeatherForecast table, as the TemperatureC and TemperatureF fields are not present in this method, tho they are in myprojectname/WeatherForecast.cs

namespace EndToEndDB.Data.EndToEnd
{
public partial class WeatherForecast
{
public int Id { get; set; }
public DateTime? Date { get; set; }
public int? TemperatureC { get; set; }
public int? TemperatureF { get; set; }
public string Summary { get; set; }
public string UserName { get; set; }
}
}

...
..so while the authentication-identity objects are working and the CRUD functionality is too, i'd like to merely change the table to my "Products" table and the model, but very confused after reading many online tutorials and articles.

Thanks in advance
Ned


Viewing all articles
Browse latest Browse all 9386

Trending Articles