Converting .net 4.8 project to .net 8 Issues with a specific bit of entity framework config
In the old .NET framework 4.8 entity framework onModelCreating method we had this: modelBuilder.Entity<ScheduleEntry>() .Map<AdhocScheduleEntry>(m => m.Requires(p => p.Description)) .Map<PMScheduleEntry>(m => m.Requires(p…
EFCore 8.0 SaveChangesAsync Faild
Hi there, Why EFCore 8.0 SaveChangesAsync always faild? Env : Azure Functions , EFCore 8.0.10 The error msg is : An exception occurred in the database while saving changes for context type…
Blazor Server with Entity Framework Core Code First
Hello, we are currently evaluating the usability of Entity Framework Core Code First in a Blazor Server application. We try to migrate from a Database First approach where we created a DbContext instance (by a IDbContextFactory) per database…
How to fix an error System.TypeLoadException: in an swagger api project ?
System.TypeLoadException: Method 'get_LockReleaseBehavior' in type 'MySql.EntityFrameworkCore.Migrations.Internal.MySQLHistoryRepository' from assembly 'MySql.EntityFrameworkCore, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does…
efcore 迁移oracle数据库 comment 中文乱码
Microsoft.EntityFrameworkCore 7.0.9 oracle 19c SIMPLIFIED CHINESE_CHINA.AL32UTF8 环境如上,迁移到数据库后,所有注解(表注解和字段注解)中文都是乱码
Single transaction, multiple service calls to Entity Framework updating database
Hi all; I have a case with a single database defined by a single Entity Framework DbContext. I have things set up where updating the database is via services. This separates things out nicely and makes it easy to mock the database for the bUnit (Blazor…
Entity Frame Core ExecuteUpdate Compiling error
The following codes are all working great! string? newval = null; indexDB.TabeABC .Where(b => b.PropertyABC != null) .ExecuteUpdate(setters => setters.SetProperty(b => b.PropertyABC, newval)); However, this does not even pass…
Getting HTML and Javascript into entity framework database
I store some data in textboxes how do I get this into the entity framework database? <h1>Hello, world!</h1> <h2>The time on the server is @DateTime.Now </h2> <input id="lat" name="lat"…
Can't Remove-Migration because of default ID (but Add-Migration worked fine)
I messed up the seed data, and now when I try the "Remove-Migration" command I get this error. The "Add-Migration" command gave me no problems, however. Is this an error? How can I remove the migration? Unable to create a 'DbContext'…
How to fix .NET Framework error
keeps saying See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.Data.Entity.Core.EntityException: The underlying provider failed on Open.…
内存占用率很高,但任务管理器却没有显示是什么进程。
Windows10x64,16G内存, 电脑开机后占用约30%,一分钟后内存占用率达到80%左右,但任务管理器没有占用内存过高的程序。 使用poolmon查看,得知是CTNP占用内存过高,运行 c:>findstr /m /l /s CTNP *.sys,没有答案。 Tag Type Allocs Frees Diff Bytes Per Alloc CTNP Nonp 2315 ( …
Using IDENTITY_INSERT with FK_ChildTable_ParentTable?
Hello, Wrapping SaveChanges with ON and OFF works fine with individual tables. But not in case of a parent-child relationship where a foreign key exists. Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column…
How to fix "The type initializer for 'WinRT.ActivationFactory1' threw an exception."
Hi there, I'm developing a mobile application with Net.MAUI, using SQLite db, EntityFrameworkCore, Net8, and I'm not able to create Migrations to manage db schema, using the following command in the Package Manager Console: Add-Migration INIT -o…
Passing ViewModel with Dictionary properties to View throws NullReferenceException
I have a ViewModel that includes two Dictionary properties, Genres and Producers, which I want to send to the View. However, when I try to loop through the Dictionary properties in the View, I get a NullReferenceException error. The data appears to be…
How to Update-Database in PM console when getting "Could not load assembly..." error?
Hello, I cannot apply migrations to database by Package Manager Console command Update-Database. On every attempt I get error: Could not load assembly "My_Project". Ensure it is referenced by the startup project 'My_Project'. Before mentioned…
How to get current User outside of Controller in another layer
In ASP.NET Core 6, I need to get the current user in service layer This is code: public class ServiceModel { private readonly IHttpContextAccessor accessor; public ServiceModel(IHttpContextAccessor accessor) { this.accessor =…
Cannot Migrate Database
Hello all, I am having issue updating the migration of my database. I am currently using .NET 9.0. I have modified one of my files to include the following: protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.UpdateData( …
Scaffolding (DB first) does not generate Model class
Hi I tried to generate model class based on existing view. This is the command I used in PMC: Scaffold-DbContext "//connectionstring" Oracle.EntityFrameworkCore -schema //schema -table //table -OutputDir Models It seems like it is working.…
How to fix DbContextOptions resolving properly from services to apply EF migration to create database?
I'm trying to run a migration to create my initial database from code, but i'm having difficulties with proper registration of DbContextOptions. My program.cs contains the service registration: var builder = WebApplication.CreateBuilder(args); // Add…
Upload Image to ASP.NET Razor Page
Hello, How to add image upload in asp.net core razor pages to a Create and Edit page that is generated from: Add > New Scaffolded Item > Razor Pages using Entity Framework (KRUD) to save the name of image to database and upload image file to…