简体   繁体   English

实体框架未获取复杂类型的列

[英]Entity Framework isn't getting the columns for Complex Type

The goal目标

I want to get for my complex types their respective columns.我想为我的复杂类型获取它们各自的列。

The problem问题

Unlike this answer, by marc_s , in part (4) (four) , my complex type have no database columns assigned to him.这个答案不同,marc_s在第(4) (四) 部分中,我的复杂类型没有分配给他的数据库列。

To exemplify:举例说明:

例子

And before you ask, my function importing is right:在你问之前,我的函数导入是正确的:

示例 2

So, what I have to do?那么,我必须做什么?

Update 1更新 1

I have tried to add manually the properties to my complex type, but it is the best way?我尝试将属性手动添加到我的复杂类型中,但这是最好的方法吗?

Update 2更新 2

I want to add the scalars properties to my complex type automatically — like in the example I posted before.我想自动将标量属性添加到我的复杂类型 - 就像我之前发布的示例一样。

@chiefGui I did not understand your question perfectly well, but seems when you click in "Get Column Information" button, you get no columns. @chiefGui 我不太明白你的问题,但似乎当你点击“获取列信息”按钮时,你没有得到任何列。

If it's that the problem you can fix it by adding a command in you procedure.如果是这个问题,您可以通过在程序中添加命令来解决它。

Put a command like this.发出这样的命令。

ALTER PROC ProcName  /* ([,parameters] ) */
AS
BEGIN
    /* this command you make the difference */
    SET FMTONLY OFF

    /* other code here */
END

Put this in first line of inside of your procedure.把它放在你的程序内部的第一行。 Remove the procedure from EDMX, add again and try again the import.从 EDMX 中删除该过程,再次添加并再次尝试导入。 And you'll get all columns returned by your procedure.您将获得程序返回的所有列。 So de step by step will working well.所以一步一步地工作会很好。

If this is not the answer you want please add comment so I can help you.如果这不是您想要的答案,请添加评论,以便我可以帮助您。

EDITED已编辑

This happens because the EF try to getting columns headers without getting a result data.发生这种情况是因为 EF 尝试获取列标题而不获取结果数据。 If your procedure has a high level of complexity, the EF will only be able to get the information, if your code is set to check the structure before running.如果您的程序具有高度复杂性,则 EF 将仅能够获取信息,前提是您的代码设置为在运行前检查结构。

Did you notice that "Not Supported" caption next to the field name?您是否注意到字段名称旁边的“不支持”标题? Its because MySql connector can't fails to read datatypes from stored procedure resultset.这是因为 MySql 连接器无法从存储过程结果集中读取数据类型。 This is a bug in MySQL Net Connector since forever.这是 MySQL Net Connector 中的一个错误,因为它永远存在。 The work around is a create a table with the same two columns (in your example), import that table before importing the stored procedure into EDMX and when you import your stored procedure, in the Add Function Import dialog box, select "Entities" option instead of complex type, and map to that table.解决方法是创建一个具有相同两列的表(在您的示例中),在将存储过程导入 EDMX 之前导入该表,并在导入存储过程时,在“添加函数导入”对话框中,选择“实体”选项而不是复杂类型,并映射到该表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM