Добрый день.
Подскажите пожалуйста в чем может быт проблема.
Не проходить процесс инициализации БД в EntityFramework.Core при том что миграции создаются без каких либо ошибок.
>dotnet ef database update
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.76
System.ArgumentException: GenericArguments[0], 'MobileStore.Migrations.MobileContext', on 'Microsoft.EntityFrame
workCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type 'TContext'. ---> System.T
ypeLoadException: GenericArguments[0], 'MobileStore.Migrations.MobileContext', on 'Microsoft.EntityFrameworkCore
.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'.
at System.RuntimeTypeHandle.Instantiate(Type[] inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Excepti
on e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextFactory(Type contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextTypes()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextType(String name)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration,
String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
GenericArguments[0], 'MobileStore.Migrations.MobileContext', on 'Microsoft.EntityFrameworkCore.Infrastructure.ID
bContextFactory`1[TContext]' violates the constraint of type 'TContext'.
Класс контекста данных:
using Microsoft.EntityFrameworkCore;
namespace MobileStore.Models
{
public class MobileContext : DbContext
{
public DbSet<Phone> Phones { get; set; }
public DbSet<Order> Orders { get; set; }
public MobileContext(DbContextOptions<MobileContext> options)
: base(options)
{
}
}
}