更改EF 6从T4代码生成策略 [英] Change EF 6 Code Generation Strategy from T4

查看:1019
本文介绍了更改EF 6从T4代码生成策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去,我已经成功地创建EDMX文件。这是使用EF5和Visual Studio 2012年。因为我已经升级到Visual Studio 2013和EF6。现有的EF 5代码仍然有效,但现在我有一个问题。我可以创建EDMX文件,以及EntityDataSource,我可以配置数据源,它看到的表和列很好,但是当我尝试刷新模式获得:

In the past I have successfully created edmx files. This was using EF5 and Visual Studio 2012. I have since upgraded to Visual Studio 2013 and EF6. The existing EF 5 code still works, but now I have a problem. I can create edmx files, and an EntityDataSource, I can configure the data source, it sees the tables and columns fine, but when I try to refresh the schema I get:

架构不能因为来自EntityDataSource以下错误的决定:

The schema could not be determined because of the following error from the EntityDataSource:

无法(在这里我喜欢的类型)找到CLR类型

Could not find the CLR type for (my type here)

我见过上线解决方案,告诉我要改变我的代码生成策略默认(EF 5中创建的现有EDMX文件。设置为传统的ObjectContext),但它不会让我这样做是因为选项'T4'显示为灰色

I have seen a solution on-line telling me to change my Code Generation Strategy to default (the existing edmx files created in EF 5 are set as Legacy ObjectContext), but it won't let me do this because the option 'T4' is grayed out.

有没有一种方法,我可以强制代码生成策略,不使用?T4

Is there a way I can force the Code Generation Strategy to not use T4?

编辑:

帕维尔指出EntityDataSource不支持EF 6.是否有可用的一个教程显示了如何连接到EF 6的简单的一步一步的指导?我有从书开始ASP.Net 4我所有的EF的信息,但现在显然已经过时。我看到EF 6仍处于测试阶段。 ?也许他们会在某个阶段增加对EntityDataSource支持

Pawel states that EntityDataSource does not support EF 6. Is there a tutorial available that shows an easy step-by-step guide of how to connect to EF 6? I have got all my EF information from the book Beginning ASP.Net 4, but it is now obviously out-dated. I see that EF 6 is still in beta stage. Maybe they'll add support for EntityDataSource at some stage?

编辑2:

好吧,我被摆弄周围这个了一点,我可以使用的LinqDataSource连接。我不会有机会用它做玩了几天,但它看起来像这样的作品

OK, I've been fiddling around with this for a bit, and I can connect using LinqDataSource. I won't get a chance to play around with it much for a few days, but it looks like this works.

编辑3:

使用的LinqDataSource不起作用。唯一的CRUD操作就可以进行阅读。显然,必须使用新的EF 6.0框架(帕维尔曾建议我用MVC)的方式,但他们不可能(使用网站)彻底打破了它为我的情况下,是不是?

Using LinqDataSource doesn't work. The only CRUD operation it can perform is Read. Obviously there must be a way to use the new EF 6.0 framework (Pawel has suggested I use MVC), but they couldn't have broken it completely for my scenario (using web site), could they?

编辑4:

我已经找到了我的方案的解决方案,请参阅我的回答如下

I have found a solution for my scenario, see my answer below.

推荐答案

由于EF6变化,如果你使用的是EF6在VS2012 / VS2013唯一支持的生成策略是T4。您可以通过使用 T4模板从VS库获得基于EntityObject实体和基于ObjectContext的背景。注:EntityDataSource目前不支持EF6

Due to changes in EF6 if you are using EF6 in VS2012/VS2013 the only supported generation strategy is T4. You can get EntityObject based entities and ObjectContext based context by using T4 templates from VS Gallery. Note: EntityDataSource does not currently support EF6.

修改

的预览与EF6支持EntityDataSourceControl现在的可用

The preview of the EntityDataSourceControl with EF6 support is now available

这篇关于更改EF 6从T4代码生成策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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