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