Unable to locate metadata resource for: http://localhost:53414/api/data/ {Development}
See original GitHub issueI’ve encountered this error recently on a test site I’ve been working on of BPP.
I tried to replicate and created a clean version cloned from the development branch as of yesterday to stage the error.
The error happens when I login to the site after creating a new datamodel in Breeze.
Here’s the full error:
blazor.server.js:19 [2020-09-20T15:19:23.687Z] Error: System.Exception: Unable to locate metadata resource for: http://localhost:53414/api/data/
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Breeze.Sharp.MetadataStore.UpdateStructuralTypeFromJNode(JNode jNode, Boolean isFromServer)
at Breeze.Sharp.MetadataStore.<>c__DisplayClass53_0.<DeserializeFrom>b__2(JNode jn)
at Breeze.Sharp.Core.EnumerableFns.ForEach[T](IEnumerable`1 items, Action`1 action)
at Breeze.Sharp.MetadataStore.DeserializeFrom(JNode jNode, Boolean isFromServer)
at Breeze.Sharp.MetadataStore.ImportMetadata(JNode jNode, Boolean isFromServer)
at Breeze.Sharp.MetadataStore.ImportMetadata(String metadata, Boolean isFromServer)
at Breeze.Sharp.MetadataStore.FetchMetadata(DataService dataService, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Breeze.Sharp.MetadataStore.FetchMetadata(DataService dataService, CancellationToken cancellationToken)
at Breeze.Sharp.EntityManager.FetchMetadata(CancellationToken cancellationToken, DataService dataService)
at Breeze.Sharp.EntityManager.FetchMetadata(DataService dataService)
at Breeze.Sharp.EntityManager.ExecuteQuery(EntityQuery query, CancellationToken cancellationToken)
at Breeze.Sharp.EntityManager.ExecuteQuery[T](EntityQuery`1 query, CancellationToken cancellationToken)
at BlazorBoilerplate.Shared.Services.ApiClient.GetUserProfile() in C:\*\repos\TestBreezeComplex\src\Shared\BlazorBoilerplate.Shared\Services\ApiClient.cs:line 21
at BlazorBoilerplate.Shared.Services.AppState.GetUserProfile() in C:\*\repos\TestBreezeComplex\src\Shared\BlazorBoilerplate.Shared\Services\AppState.cs:line 62
at BlazorBoilerplate.Theme.Material.Shared.Layouts.MainLayout.OnInitializedAsync() in C:\*\repos\TestBreezeComplex\src\Shared\Modules\BlazorBoilerplate.Theme.Material\Shared\Layouts\MainLayout.razor:line 70
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Here’s the changes:
DataModel: Test.cs
using BlazorBoilerplate.Infrastructure.Storage.DataInterfaces;
using BlazorBoilerplate.Shared.Dto.Db;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace BlazorBoilerplate.Infrastructure.Storage.DataModels
{
public partial class Test : IAuditable, ISoftDelete
{
[Key]
public long Id { get; set; }
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public Statuses RecordStatus { get; set; }
}
}
DTO: Test.Cs
using BlazorBoilerplate.Shared.Dto.Db;
using Breeze.Sharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace BlazorBoilerplate.Shared.Dto
{
public partial class Test : BaseEntity
{
public Int64 Id
{
get { return GetValue<Int64>(); }
set { SetValue(value); }
}
public String Name
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public String Address1
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public String Address2
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public String City
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public String State
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public String Zip
{
get { return GetValue<String>(); }
set { SetValue(value); }
}
public Statuses RecordStatus
{
get { return GetValue<Statuses>(); }
set { SetValue(value); }
}
//Add the following for the purpose of IAuditable and ISoftDelete functionality
public Guid? CreatedById
{
get { return GetValue<Guid?>(); }
set { SetValue(value); }
}
public DateTime CreatedOn
{
get { return GetValue<DateTime>(); }
set { SetValue(value); }
}
public Boolean IsDeleted
{
get { return GetValue<Boolean>(); }
set { SetValue(value); }
}
public Guid? ModifiedById
{
get { return GetValue<Guid?>(); }
set { SetValue(value); }
}
public DateTime ModifiedOn
{
get { return GetValue<DateTime>(); }
set { SetValue(value); }
}
public ApplicationUser CreatedBy
{
get { return GetValue<ApplicationUser>(); }
set { SetValue(value); }
}
public ApplicationUser ModifiedBy
{
get { return GetValue<ApplicationUser>(); }
set { SetValue(value); }
}
}
}
GlobalEnums.cs.
using System;
using System.Collections.Generic;
using System.Text;
namespace BlazorBoilerplate.Shared.Dto.Db
{
public enum Statuses
{
Pending,
Complete,
Reviewed
}
}
ApplicationDbContext.cs:
public DbSet<Test> Tests { get; set; }
ApplicationController.cs:
[HttpGet]
public IQueryable<Test> Tests()
{
return persistenceManager.GetEntities<Test>().Include(i => i.CreatedBy).Include(i => i.ModifiedBy).OrderBy(i => i.Id);
}
ApiClient.cs (and its reference in IApiClient.cs):
public async Task<QueryResult<Test>> GetTests()
{
return await GetItems<Test>(from: "Tests", orderByDescending: i => i.CreatedOn);
}
Thank you for all your help,
Jeff
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
MetadataException: Unable to load the specified metadata ...
The reason is Res://*/ is a uri which points to resources in the CURRENT assembly. If the Edm is defined in a different...
Read more >Unable to load the specified metadata resource - Ozkary
The error means that there is a problem with finding the metadata information to allow the Entity Framework to work properly and translate ......
Read more >Unable to load the specified metadata resource
After the upgrade, I get the following message "Unable to load the specified metadata resource." My Config entry for Devart.Data.Salesforce.
Read more >Re: "Unable to load the specified metadata resource" error ...
Looking at the exception, it's a System.Data.MetadataException, which isn't something Autofac throws. Given the stack trace being in an Autofac ...
Read more >Entity Framework : Unable to load the specified metadata ...
Entity Framework : Unable to load the specified metadata resource. So I've been working on a code base for a financial system today...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s it, OMG can’t believe I missed it. Thank you 😄
Nice work @GioviQ