如何转换为可在EF中使用的对象 [英] How do I cast to an object that can be used in EF

查看:69
本文介绍了如何转换为可在EF中使用的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有一个问题,我使用实体框架来更新和创建一个音乐表。我有一个测试项目,我使用名为MusicBulider的构建器类构建实体。构建器类继承Music模型。



当我尝试创建类并通过EF更新时,由于EF无法处理构建器类,因此出现错误。



有没有办法将Builder类强制转换为我想要更新的Object?每次我尝试运行测试时都会出现以下错误。



EntityFramework.dll中出现'system.InvalidOperationException'类型的例外,但未在用户代码中处理。



附加信息:无法找到实体类型'TestRate.Tests.MusicBuilder'的映射和元数​​据信息



我希望我已经提供了足够的信息。



提前致谢。

Hi there,

I have a problem where I am using entity framework to update and create a Music table. I have a testing project where i built the entity using a builder class called MusicBulider. The builder class inherits the Music model.

When I try and create the class and update via EF, I get an error as the EF cannot handle the builder class.

Is there a way where I can cast the Builder class into the Object that I want to update? Everytime I try and run my test I get the following error.

An exception of type 'system.InvalidOperationException' occured in EntityFramework.dll but was not handled in user code.

Additional information: Mapping and metadata information could not be found for entity type 'TestRate.Tests.MusicBuilder'

I hope I have given enough information.

Thanks in advance.

推荐答案

这篇关于如何转换为可在EF中使用的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆