2014-02-19 34 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