- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 EntityFramework.BulkInsert
扩展名,但我不断收到 Type 'MyEntity.CallDetail' is not found in context 'MyEntity.MyEntities'
的异常.我将此异常跟踪到 DBMapping
EntityFramework.MappingAPI
中的类.抛出它的方法是:
public IEntityMap this[string typeFullName]
{
get
{
if (!_tableMappings.ContainsKey(typeFullName))
throw new Exception("Type '" + typeFullName + "' is not found in context '" + _contextTypeName + "'");
return _tableMappings[typeFullName];
}
}
我的问题是,这是 EntityFramework.MappingAPI
中的错误吗?或者这是我的代码中的一些东西?
我的上下文类:
public partial class MyEntities : DbContext
{
public MyEntities()
: base("name=MyEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<CallDetail> CallDetail { get; set; }
public virtual DbSet<PhoneState> PhoneStates { get; set; }
public virtual DbSet<Skill> Skills { get; set; }
public virtual DbSet<Team> Teams { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<StateLog> StateLogs { get; set; }
}
我假设错误是由于一切都是 DBSet<...>
引起的而不仅仅是类型,但我可能是错的。
如果它在我的代码中(这是最有可能的),我需要做什么才能使它工作?
编辑:感谢@BenRobinson,问题是由 EF 映射引起的。我发现其他人也遇到过与 EntityFramework.MappingAPI
类似的问题在发现的 DB 优先模型上 here , here , 和 here .由于我是 EF 的新手,我希望有人能在 edmx
中看到问题这可能是导致问题的原因。以下是 edmx 文件中的信息:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="my_contactModel.Store" Provider="MySql.Data.MySqlClient" ProviderManifestToken="5.6" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityType Name="call_detail">
....
</EntityType>
<EntityContainer Name="my_contactModelStoreContainer">
<EntitySet Name="call_detail" EntityType="Self.call_detail" Schema="my_contact" store:Type="Tables" />
....
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="MyContactModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="CallDetail">
....
</EntityType>
<EntityContainer Name="MyEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="CallDetail" EntityType="MyContactModel.CallDetail" />
....
</EntityContainer>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="my_contactModelStoreContainer" CdmEntityContainer="MyEntities">
<EntitySetMapping Name="CallDetail">
<EntityTypeMapping TypeName="MyContactModel.CallDetail">
<MappingFragment StoreEntitySet="call_detail">
....
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
</edmx:Edmx>
最佳答案
我遇到了同样的问题,只需更新我的 EntityFramework.MappingAPI 就可以解决它! NuGet MappingAPI .更新后,我只是重建了我的项目,不再有异常。
关于c# - 在上下文中找不到类型,可能是映射问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25853967/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!