Blazor Wasm не может использовать ядро ​​Ontity FrameworkC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Blazor Wasm не может использовать ядро ​​Ontity Framework

Сообщение Anonymous »

Я пишу приложение Blazor WASM в .NET 8. Сегодня я попытался добавить извлечение данных базы данных в свое приложение, но я не могу получить основную работу фреймворта. Я использую одни и те же библиотеки, что и всегда. Когда я пытаюсь запустить приложение и пытаюсь извлечь данные из контекста в onInitializedAsync < /code> Метод. .Aspnetcore.components.webassembly.rendering.webassemblyrenderer [100] < /p>
Компонент рендеринга беззабочного исключения: тип mysql.data.entityframeworkcore.infrastructure.internal.mysqloptionseensens Метод none
system.typeloadexception: type mysql.data.entityframeworkcore.infrastructure.internal.mysqloptionsextension+extensionInfo имеет недопустимый vtable method slot 5 с методом < /p>
at microsoft.entityframeformcore. .Gethashcode ()

at system.collections.concurrent.concurrentdictionary2[[Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptions, Microsoft.EntityFrameworkCore, Version=8.0.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.ValueTuple 2 [[System.iserviceProvider, System.componentModel, версия = 8.0.0.0, культура = нейтральный, publickeyToken = b03f5f7f11d50a3a], [System.collections.generic.idicticaryary2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd[ValueTuple 2] (idbcontextoptions, фанк3 valueFactory, ValueTuple< /code> 2 FactoryArgument)

at microsoft.entityframeworkcore.internal.serviceprovidercache.getoradd (idbcontextoptions, boolean providerrequired)

at microsoft.entityframeworkcore.dbcontext.get_contextsersers ()
at microsoft.entityframeworkcore.dbcontext.get_model ()

at microsoft.entityframeworkcore.internal.internaldbset1[[MyProject.Components.Models.Player, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_EntityType() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet< /code> 1 [[[myproject.components.models.player, myproject, version = 1.0.0.0, culture = нейтральный, publickeytoken = null]]. checkstate ()

at microsoft.entityframeworkcore.internal ()

at microsoft.entityframeworkcore.internal () 1 [[myproject.components.models.player, myproject, version = 1.0.0.0, culture = нейтральный, publickeytoken = null]]. System.collections.generic.ienumerable.getEnumerator ()
at system. .Collections.generic.list1[[MyProject.Components.Models.Player, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]..ctor(IEnumerable< /code> 1 Collection)
at system.linq.enumerable.tolist [player] (ienumerable`1 источник)
at myproject.pages.home.oninitializedAsync () в C: \ users \ filipmráz \ Source \ Repos \ myProject \ myProject \ pages \ home.razor: строка 112
at microsoft.aspnetcore.components.componentbase.runinitandSetParametersAsync () < /p>
< /blockquote>
Это код: < /p>
protected override async Task OnInitializedAsync()
{
var a = context.CreateDbContext().Players.ToList();

foreach (var item in a)
{
Console.WriteLine(item.Id);
}
}

Это мой dbcontext и объект dbset:
public class CustomDbContext : DbContext
{
public DbSet Players { get; set; }
public DbSet Tournaments { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySQL("myConString");
}
}

[Table("Players")]
public class Player
{
public int Id { get; set; }
}


Подробнее здесь: https://stackoverflow.com/questions/790 ... ework-core
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»