缺少与.NET 3.5实体框架的东西? [英] Missing something with Entity Framework for .NET 3.5?

查看:82
本文介绍了缺少与.NET 3.5实体框架的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有两个相关表与.NET3.5SP1中的FK链接时,是不是有EF创建必要的实体?我看到支持这种方式的复选框被禁用,但它在.NET4中可用。



我有一个DB只有与其关系的表。我需要构建一个Silverlight应用程序(SL4),可以管理这个应用程序中的数据。我不能在服务器上使用.NET4 ...只有.NET3.5SP1,所以EF4中的FK关系位不可用。希望避免建立尽可能多的管道,尽可能从SL4应用程序返回到DB。

解决方案

您在项目设置中使用Visual Studio 2010和目标.NET Framework 3.5?



如果是这样,我想用禁用复选框表示复选框以包括用于从数据库创建实体模型的向导中的外键列。 (这个复选框在VS2008中完全不存在,并且当在VS2010中定位.NET 4.0时,它不会被禁用,因此我的关于VS2010与.NET 3.5的理论。)



那么对于你来说还有一个比较好的消息:这个复选框并不意味着不会通过外键约束链接的表创建Entity关系。它们也将在Entity Framework 1(.NET 3.5)中创建。您只能不具有代表您的外键列的标量Entity属性。 (这个复选框 - 仅在.NET 4中可用 - 被检查,将包括模型中的这些属性。)而您必须处理实体中引用的对象(检查,如果它们被加载,手动加载或将它们直接包含在查询中,等等)。



所以在.NET 3.5中使用Entity模型中的关系,但外键约束仍然正确表示并自动创建。只需让向导运行并浏览生成的实体模型。


Is it not possible to have EF create the necessary entities when I have two related tables linked with a FK in .NET3.5SP1? I see where the checkbox to support this is disabled but it is available in .NET4.

I've got a DB that has only tables with relationships in it. I need to build a Silverlight app (SL4) that allows management of the data within this app. I can't use .NET4 on the server... only .NET3.5SP1 so FK relationship bit in EF4 isn't available to me. Looking to avoid building as much of the plumbing to get back to the DB from the SL4 app as possible...

解决方案

Do you use Visual Studio 2010 and target .NET Framework 3.5 in your project settings?

If that is the case, I guess with "disabled checkbox" you mean the checkbox to include foreign key columns in the wizard for creating an Entity Model from a database. (This checkbox doesn't exist at all in VS2008 and when targeting .NET 4.0 in VS2010 it isn't disabled. Hence my theory about VS2010 with .NET 3.5.)

So, then there are relatively good news for you: This checkbox does NOT mean that no Entity relationships would be created from tables linked by foreign key constraints. They WILL be created, also in Entity Framework 1 (.NET 3.5). You only won't have scalar Entity properties which represent your foreign key columns. (This checkbox - only available in .NET 4 -, being checked, will include those properties in the model.) Instead you always have to deal with the referenced objects in your entities (check, if they're loaded, load them manually or include them directly in queries, and so on).

So you have a bit less comfort when working with relationships in the Entity model in .NET 3.5 but the foreign key constraints are still represented correctly and automatically created. Just let the wizard run and explore the generated Entity model.

这篇关于缺少与.NET 3.5实体框架的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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