![](/img/trans.png)
[英]Entity Framework Core seed entity problem
我嘗試為以下實體添加遷移,但出現錯誤。 我已經盡一切努力讓它工作,但我覺得我遺漏了一些明顯的東西。 代碼如下 “無法添加‘Bug’類型的種子實體,因為沒有為所需屬性‘UserId’提供任何值” 我已經嘗試了上述方法以及查找影子鍵並分離 Bug 和 User 實體 ...
[英]Entity Framework Core seed entity problem
我嘗試為以下實體添加遷移,但出現錯誤。 我已經盡一切努力讓它工作,但我覺得我遺漏了一些明顯的東西。 代碼如下 “無法添加‘Bug’類型的種子實體,因為沒有為所需屬性‘UserId’提供任何值” 我已經嘗試了上述方法以及查找影子鍵並分離 Bug 和 User 實體 ...
[英]How to write unit test case for SaveChangesAsync()
我正在為我的 Entity Framework Core SaveAsync方法編寫單元測試用例。try { // Here add business logic to insert record in to new database var dbObj = new TableNa ...
[英]How to config two primary keys with data annotation in entity framework core?
我正在嘗試使用實體框架核心中的數據注釋為我的 model 配置兩個主鍵 我在 inte.net 中嘗試了一些解決方案,但沒有用。 有人可以幫我嗎,非常感謝 ...
[英]Error trying to update migration .NET Maui with EFcore
在 my.Net MAUI 項目中,我正在嘗試更改更新我的遷移。 我向我的 model 添加了一個屬性並做了; 數據包管理器控制台中的 Add-Migration AddBlogCreatedTimestamp 數據包管理器控制台中的更新數據庫它告訴我“構建成功”但也給我錯誤“啟動項目目標平台‘An ...
[英]Entity Framework Core Insert list of one-to-one-or-zero (shared primary key association) foreign key conflict
我正在嘗試插入一個對象列表。 這些對象由 2 個獨立的子對象組成,通過 0 到 1 的關系鏈接。 如果我一次插入一個 object,它會起作用,但如果我嘗試插入多個,對SaveChanges的調用會引發“外鍵”錯誤。 我知道 0 對 1 關系需要知道主要關系 object 索引。 但是,有沒有辦法解 ...
[英]EF Core The LINQ expression 'DbSet() could not be translated
我在這里錯過了什么?IQueryable<IsActiveCustomerProviderRefDto> search = from customerProviderRef in _database.CustomerProviderRef join customerTra ...
[英]Entity Framework Core 6 - System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values
我在 .NET 6.0 上使用 EF Core 6 並查看此錯誤: System.Data.SqlTypes.SqlNullValueException: 數據為 Null。無法對 Null 值調用此方法或屬性錯誤消息應指示 EF Core 正在嘗試讀取所需屬性的值,即數據庫中不應具有 null ...
[英]EF Core Transactions raw SQL memory use
我試圖了解具有大量內部命令的 EF Core 事務如何使用 memory。 假設我有這樣的代碼: MyReader正在讀取從某個來源流式傳輸的非常大(數百萬行)的記錄集合。 我的問題是: myObj變量引用的對象是否可以在我們提交事務之前被垃圾回收,或者我們是否有效地將它們全部加載到 memor ...
[英]How to update tables in many-to-many relationship in Entity Framework Core?
我有兩個處於多對多關系中的實體和 3 個表: 顧客店鋪 CustomerAndShopAssignemnt(連接表) 例如,我有商店清單: 我想添加一個新客戶,為此我選擇了 2 家商店(例如 ShopA 和 ShopC)。 我所做的是: 我從 EF 那里得到錯誤,它不能將實體與相同的主鍵放在一起。 ...
[英]Many-to-many with TPC inheritance in EF Core
我在使用 TPC inheritance 配置 May-to-many 時遇到問題 多對多關系在抽象 class 上,生成的表是測試B 父類 ParentClassTestB:多對多關系 Child_A:對 ParentClass 有 FK Child_B:對 ParentClass 有 FK 我 ...
[英]Why is Group By translating in Order By by Entity Framework?
我在 .NET 7 中使用實體框架。 我有 3 個實體: 其中包含ProfessorId的Course 具有CourseId等的Grade Professor 我想獲取所有分配給一位教授並且至少有 1 個等級與之關聯的課程,並在Dictionary<string, CourseViewMod ...
[英]Oracle Entity Framework/Managed Data Access Core and connection pool leak with proxy user
我們最近從 Oracle.ManagedDataAccess.EntityFramework 升級到 Oracle.EntityFrameworkCore(我們在 .net 標准 2.0 上)。 當我們連接到數據庫時,我們使用代理憑據,連接字符串如下: User Id=changingUserId ...
[英]EF Core query and projection to dto doesn't fill the property
如何編寫 EF Core 查詢以按特定順序填充屬性?public record PersonDto : BaseDto //Id is Guid { public string Firstname { get; init; } public string Lastname { get ...
[英]How to run SQL scripts in .NET 6 using EF Core Code first migration
我的 class 庫項目中的每個遷移都有以下文件夾結構。 我如何獲得帶有名稱的正確文件路徑並在遷移文件的 Up 方法中運行它。 對於每次遷移,我都將文件夾用作 1,2 等等。 ...
[英]View returns an error from an abstract type
我有一個抽象的音樂會類型和 3 個繼承自基礎的音樂會類 (RegularConcert, Party, ClassicalConcert) ,它們都映射到數據庫中它們自己的表,問題是我無法在單個視圖中獲取所有它們(可能是因為 Concert 是抽象的)並且我在我的 controller 中得到了一 ...
[英]How do I resolve the service for a type during an Entity Framework Core database update?
我正在嘗試通過為 .fmbot 運行現有數據庫遷移來初始化 PostgreSQL 數據庫。 我出於這個問題的目的制作了一個 MVCE,但這里有GitHub 回購協議以供參考。 這是我的文件結構: 這是我精簡的 class,用於處理FMBot.Persistence.EntityFrameWork ...
[英]How to define DbContext scope in WPF application similar to ASP.NET?
我想使用相同的技術從 ASP.NET MVC 和 WPF 訪問我的數據庫,並決定使用 EF Core。 在 ASP.NET 中,我可以將 DbContext(UnitOfWork、AppBLL 等)注入到 Controller 中,它的生命周期僅限於請求/響應操作。 據我了解,scope 是使用 ...
[英]Why does EF Core 7 always translate my datetime where clause to '0001-01-01T00:00:00.0000000'
我很確定我已經在 EF Core 6 中完成了此操作並且它之前有效,但現在我已經升級到 EF Core 7 並且我的日期時間值正在轉換為 '0001-01-01T00:00:00.0000000' 例如: 在控制台中產生這個: 我的印象是 where 子句中的這種比較應該有效嗎? ...
[英]How to Get Column Name From Entity Type Configuration With Property Name In EF Core
我有這樣的 EntityTypeConfiguration class。 我想通過使用屬性 DummyType.SecretId 來檢索列名:“secretID”: ...
[英]Entity Framework Core bidirectional relationship
如何使雙向關系在 Entity Framework Core 中工作? 做.net 6 英孚核心 6.0.13 數據庫上下文 class 遷移錯誤無法在“Department.Users”和“AppUser.Department”之間創建關系,因為“Department.Manager”和“AppU ...