I am currently trying with Blazor server to get a list. But when the list is called via the service I just get an error:
Error: System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call. ---> MySqlConnector.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. at MySqlConnector.Core.ServerSession.ConnectAsync(ConnectionSettings cs, MySqlConnection connection, Int32 startTickCount, ILoadBalancer loadBalancer, IOBehavior ioBehavior, CancellationToken cancellationToken) in //src/MySqlConnector/Core/ServerSession.cs:line 433 at MySqlConnector.Core.ConnectionPool.ConnectSessionAsync(MySqlConnection connection, String logMessage, Int32 startTickCount, IOBehavior ioBehavior, CancellationToken cancellationToken) in //src/MySqlConnector/Core/ConnectionPool.cs:line 363
i am currently calling in the Program.cs:
builder.Services.AddScoped<Organization>().AddDbContext<OrganizationDbContext>().AddEntityFrameworkMySql();
then i try to inject the Organization.
in the Organization there is:
public Organization()
{
this.organizationDBContext = new OrganizationDbContext();
}
so the funny part about all that is in the unit test the external project works just perfect(also if i call new Organization in the OnInitializedAsync sometime it works sometime it doesn't idk why).
My unit test which works perfectly fine:
Organization org = new Organization();
var customers = org.Customers.GetCustomers().ToList();
i get a list with the customers, how should i do this in blazor server? Thanks!
For all of you who have the same error, this is the right way, keep an eye on your docker environment^^