在部分类属性没有出现在数据源窗口! [英] Properties in partial class not appearing in Data Sources window!

查看:171
本文介绍了在部分类属性没有出现在数据源窗口!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实体框架已经创建了所需的部分类。我可以将这些部分类的数据源窗口和属性显示预期。不过,如果我向任何一个类在一个单独的源文件中的这些特性甚至不经过编译出现在Data Sources窗口,并刷新。

Entity Framework has created the required partial classes. I can add these partial classes to the Data Sources window and the properties display as expected. However, if I extend any of the classes in a separate source file these properties do not appear in the Data Sources window even after a build and refresh.

在部分类跨源文件的所有属性,预计在数据源窗口,除非局部类已创建了EF工作。

All properties in partial classes across source files work as expected in the Data Sources window except when the partial class has been created with EF.

编辑:删除有问题的表EDM设计,加回其中的所有工程预计之后。几乎没有一个长期的解决方案。任何人都碰到过类似的问题?

After removing the offending table for edm designer, adding back in it all works are expected. Hardly a long term solution. Anyone else come across a similar problem?

推荐答案

我已经使用了以下解决方法:

I have used the following work around:

步骤1 ...创建必需项目 在您的解决方案创建两个项目: 1 - 应用程序项目(这样的应用程序,你的工作,例如Windows窗体应用程序) 2 - datalayer项目(一个类库项目,一个使DLL的作为构建输出)

Step 1... Create Required Projects In your solution create two projects: 1 - the application project (so the app you are working e.g. a windows forms application) 2 - the datalayer project (a class library project, the one that makes DLL's as a build output)

步骤2 ...链接项目 在应用程序项目,添加项目引用datalayer项目,(引用 - 添加引用 - 项目选项卡)

Step 2... Link The Projects In the application project, add a project reference to the datalayer project, (references - add reference - project-Tab)

第三步......在部分类创建属性 在datalayer项目: - 如果您使用的是本地数据库中添加数据库文件 - 添加一个新的LINQ to SQL类项目(.dbml文件) - 从服务器资源管理器添加所需的表设计器表 - 右击类之一,在设计和选择查看code' - 你将采取与已经完成的部分类信息的文件。 - 使局部类公 - 创建一个测试性能,例如:    公共字符串测试    {        {返回TEST;}    } - 建立datalayer项目 - 你现在又增加一个属性到部分类的你的设计师内置类之一的...

Step 3... Create a property in the partial class In the datalayer project: - add the database file if you are using a local database - add a new Linq to SQL classes item (.dbml file) - add the desired tables to the Designer sheet from the server explorer - right click one of the classes in the designer and select 'View Code' - you will be taken to a file with the partial class information already completed. - make the partial class public - create a test property eg: public string TEST { get{return "TEST";} } - build the datalayer project - you have now added a property to the partial class of one of your designer built classes...

第4步 - 添加数据源 - 在你的应用程序项目 - 转到数据源选项卡,并添加一个新的对象的数据源,选择您所添加的部分类属性太类

Step 4 - Add Datasources - in your application project - go to the datasources tab and add a new object datasource, selecting the class you added the partial class property too.

  • 您应该看到在数据源的测试属性查看...

全部完成

我觉得它的工作原理,因为具有.dbml文件和局部类在一个单独的项目,并通过DLL在应用程序项目访问..势力的Visual Studio编译使之能够在所有的应用程序项目...相到DLL和独立的临时文件,似乎让部分类属性关闭数据源列表发生时,一切都在一个项目。

I think it works because having the .dbml file and the partial class in a separate project and accessing via a DLL in the application project.. forces Visual Studio to compile and makes everything available in the application project... as opposed to a dll and separate temp file that seems to happen when everything is in the one project leaving the partial class properties off the datasources list..

再加上它不是太糟糕了......有你datalayer一个单独的项目,使得它可重复使用的项目之间..:D

plus its not too bad.. having a separate project for your datalayer makes it reusable between projects.. :D

希望工程的人......

hope it works for someone...

这篇关于在部分类属性没有出现在数据源窗口!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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