2014-02-19 27 views
0

我尝试手动创建数据模型的元数据时遇到了一些问题。更具体地说,我使用以下命令创建元数据的字符串表示,然后将其保存到本地文件中。在BreezeJS中创建手动元数据

var metadata = JObject.Parse(new EFContextProvider<HelixDtoContext>().Metadata()); 

虽然有一些缺失的信息,当我这样做。以下Dto

public class LayoutManagerState 
{ 
    public string Widgets { get; set; } 
} 


public class AppState 
{ 
    public int Id{ get; set; } 
    public ViewOptionsDialogState ViewOptionsDialogState { get; set; } 
    public LayoutManagerState LayoutManagerState { get; set; } 
    ... 
} 

我期望元数据包含LayoutManagerState复杂属性;但它不这样做。

"entityType": [ 
    { 
    "name": "AppState", 
    "key": { 
     "propertyRef": { 
     "name": "Id" 
     } 
    }, 
    "property": [ 
     { 
     "name": "Id", 
     "type": "Edm.Int32", 
     "nullable": "false", 
     "annotation:StoreGeneratedPattern": "Identity" 
     }, 
     { 
     "name": "ViewOptionsDialogState", 
     "type": "Edm.Self.ViewOptionsDialogState", 
     "nullable": "false" 
     } 
    ] 
    }, 

正如您所见,元数据中没有名称为LayoutManagerState的属性。

回答

0

我无法重现您的失败。

我把现有的应用程序(待办的一个例子)和下降的两大类,像这样:

public class LayoutManagerState { 
    public string Widgets { get; set; } 
} 

public class AppState { 
    public int Id{ get; set; } 
    public LayoutManagerState LayoutManagerState { get; set; } 
} 

我加入了新DbSetDbContext这样的:

public DbSet<AppState> AppStates { get; set; } 

然后我看着通过电线发送的元数据......它看起来很好。这里有你的复杂类型三个实体类型定义顶部:

"complexType": { 
    "name": "LayoutManagerState", 
    "property": { 
    "name": "Widgets", 
    "type": "Edm.String", 
    "maxLength": "4000", 
    "fixedLength": "false", 
    "unicode": "true" 
    } 
}, 
"entityType": [ 
    { 
    "name": "AppState", 
    "key": { 
     "propertyRef": { 
     "name": "Id" 
     } 
    }, 
    "property": [ 
     { 
     "name": "Id", 
     "type": "Edm.Int32", 
     "nullable": "false", 
     "annotation:StoreGeneratedPattern": "Identity" 
     }, 
     { 
     "name": "LayoutManagerState", 
     "type": "Edm.Self.LayoutManagerState", 
     "nullable": "false" 
     } 
    ] 
    }, 
    { 
    "name": "TodoItem", 
    "key": { 
     "propertyRef": { 
     "name": "Id" 
     } 
    }, 
    "property": [ 
     { 
     "name": "Id", 
     "type": "Edm.Int32", 
     "nullable": "false", 
     "annotation:StoreGeneratedPattern": "Identity" 
     }, 
     { 
     "name": "Description", 
     "type": "Edm.String", 
     "maxLength": "30", 
     "fixedLength": "false", 
     "unicode": "true", 
     "nullable": "false" 
     }, 
     { 
     "name": "IsDone", 
     "type": "Edm.Boolean", 
     "nullable": "false" 
     } 
    ] 
    } 
], 

微风进口它只是罚款也足以证明这个测试:

manager.metadataStore.getEntityType('LayoutManagerState'); // returns the complex type 

你认为这种差异帐户是什么?

+1

我找到了问题;我的解决方案中有以下项目。 1)MyApp.Models 2)MyApp.Dtos 3)MyApp.UI 4)MyApp.MetadataGenerator。当MVC应用程序启动时(MyAPP.UI),我调用返回元数据字符串的MyApp.MeatadataGenerator中的方法。当我这样做时,我没有得到我的数据模型的完整表示。但是,如果我将MetadataGenerator作为独立控制台应用运行,那么LayoutManagerState将包含在元数据中。 – ppoliani