实体框架4.1的DbContext产生的问题 [英] Entity Framework 4.1 DbContext generator problems

查看:201
本文介绍了实体框架4.1的DbContext产生的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的实体框架4.1和我真的想转换到POCO类为我的模型。我发现这是非常容易使用,当你安装EF 4.1中提供的的DbContext生成器项目。这也正是我想要它做的事和所产生的的DbContext对象和所有的波苏斯我现有的EDMX模型。

我跑的应用和测试,它仍然在工作。它是。满意这个我删除EDMX文件和T4模板,并开始重组我的新波苏斯。然而,得到它正确地重新打造后,我遇到了运行时的问题。当实例化的DbContext是无法找到的元数据文件:.csdl,.ssdl,和放大器; .msl(我真的不知道它们是什么,只是说它们都是EF连接字符串的一部分)。

将回到我的EDMX后,它运行得很好了。我真的不希望EDMX文件了。我真的想坚持到POCO类,而忘记了EDMX曾经存在;尤其是因为我不希望它运行的T4模板和再生我的波苏斯。

我有四个相关问题:

  1. 为什么我必须保持EDMX在我的项目?
  2. 是否有解决方法吗?
  3. 在会发生什么事,当你做真正的code-第一与EF 4.1,它在哪里的呢?让这些元数据文件
  4. 什么是这些元数据文件呢?
解决方案

您应该<一href="http://stackoverflow.com/questions/7294571/what-is-the-difference-between-that-various-data-templates-microsoft-provides">read这。它描述了不同的项目类型。

简单的回答是,你使用的DbContext发生器时需要的.edmx文件。如果你想用code首先,你要么描述模型用手工或使用实体框架电动工具CTP1以反向工程code第一款车型。

I am new to Entity Framework 4.1 and I really wanted to transition to POCO classes for my model. I found that this was very easy using the "DbContext Generator" item provided when you install EF 4.1. It did exactly what I wanted it to do and generated the DbContext object and all the POCOs for my existing EDMX model.

I ran the app and tested that it was still working. It was. Happy with this I deleted the EDMX file and the T4 templates and began reorganizing my new POCOs. However, after getting it to build properly again I encountered a runtime problem. When instantiating the DbContext it is unable to find the metadata files: .csdl, .ssdl, & .msl (I really don't know what they are, just that they are part of all EF connection strings).

After putting back my EDMX it ran fine again. I really don't want the EDMX file anymore. I would really like to stick to POCO classes and forget that the EDMX ever existed; especially because I don't want it running those T4 templates and regenerating my POCOs.

I have four related questions:

  1. Why do I have to keep the edmx in my project?
  2. Is there a workaround for this?
  3. What happens when you do true "code-first" with EF 4.1, where does it get those metadata files from?
  4. What are those metadata files anyway?

解决方案

You should read this. It describes the different project types.

The short answer is you need the .edmx file when using the dbcontext generator. If you want to use Code First, you have to either describe the model by hand or use the Entity Framework power tools CTP1 to reverse engineer a code first model.

这篇关于实体框架4.1的DbContext产生的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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