ef-fluent-api

    0熱度

    1回答

    下面的代碼工作正常,直到添加組合鍵。添加複合鍵後,我只能編輯現有的記錄,無法添加新的記錄。我想Code和CompanyId列成爲組合鍵。 這是錯誤: Cannot insert explicit value for identity column in table 'CostCenters' when IDENTITY_INSERT is set to OFF. 尋找SO解決方案後及以下線路添加(

    0熱度

    1回答

    我們正試圖讓我們用流利的API配置,而不是數據的註釋乾淨的數據模型來重新配置我們的EF項目。我們有現有的表格,現在我正試圖驗證我的努力。 這裏是舊的(部分)EF模型聲明: [Table("CustomerLocation")] internal class CustomerLocationEF { [Column(Order = 0), Key] public int Cu

    0熱度

    1回答

    我有項目類,其中每個項目都有其工作訂單。 這些都是在MySQL CREATE TABLE `project` ( `idProject` INT(11) NOT NULL AUTO_INCREMENT, `idCompany` INT(11) NOT NULL, `Title` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_u

    -1熱度

    1回答

    每次我試圖得到一個相關的對象,我得到的錯誤不設置到對象 相關代碼的實例 對象引用: public class Project { public int ProjectId { get; set; } public string ProjName { get; set; } public string Description { get; set; } pu

    1熱度

    1回答

    我正在使用流利的API來設置我的實體數據庫的關係。我有典型的AspNetUsers表,這個表有一個名爲Id(String)的列,它是表的主鍵。我擴展了IdentityUser併爲其提供了其他屬性,其中2個屬性是AdvisorProfile和StudentProfile。 ApplicationUser具有可選的AdvisorProfile和StudentProfile。 AdvsiorProfil

    0熱度

    2回答

    對於使用實體框架的多對多關係,我有一個相當簡單的問題。 情況是這樣的我有3種型號SectionName: public class SectionName : BaseEntity { public SectionName() { SectionsSuffix = new List<SectionSuffix>(); } [Required]

    1熱度

    2回答

    定義使用外鍵實體框架的關係是定義使用外鍵只(引用類型的無虛屬性)與FluentAPI實體框架關係的任何方式(數據模型不應該改變)? CardDataModel public class CardDataModel { public int CardId { get; set; } } CheckItemDataModel public class CheckItemDataMo

    5熱度

    3回答

    我已經搜索了一個合適的解決方案,使用EF Core 2.0,Code first和Fluent API來生成多對多關係。 一個簡單的場景是: public class Person { public Person() { Clubs = new HashSet<Club>(); } public int PersonId { get; set; }

    2熱度

    2回答

    我使用EF6代碼第一種方法來創建數據庫。當我添加遷移和更新數據庫時,默認情況下,它始終爲表中的每個外鍵創建Non-cluster Index。 我的問題:是否有任何全局設置爲EF6不創建外鍵Non-Cluster index? 我已經搜索並發現了以下解決方案 Solution 1: Remove index line from migration before updating database

    0熱度

    1回答

    以前,在創建遷移時,級聯刪除設置爲true,然後更新數據庫。我真的沒有注意到級聯消除設置爲true。 將數個遷移應用於數據庫後,我需要將級聯刪除設置爲false,但它不起作用,因爲它會繼續級聯刪除。 這是一個一對多的關係,我做了,在這裏客戶可以有許多車輛和車輛屬於一個客戶: 這是我的Customer類: public class Customer { public int Id { ge