دنبال کننده ها

۱۳۹۶ دی ۱۲, سه‌شنبه

entity framework core migrations do not work with class library, yet?

[ad_1]



I have an asp.net core project 'Api' with target:



<TargetFramework>net471</TargetFramework>


That project references another class library project 'Repository' with target:



<TargetFramework>netstandard1.4</TargetFramework>


The 'Api' project has this configured:



services
.AddEntityFrameworkSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly("Repository"))
)
.AddScoped(p => new ApplicationDbContext(p.GetService<DbContextOptions<ApplicationDbContext>>()));


When I am in the PMConsole I enter:



Add-Migration Initial



then I get this error:



Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
add-migration : Exception calling "Substring" with "1" argument(s): "StartIndex cannot be less than zero.
Parameter name: startIndex"
At line:1 char:1
+ add-migration
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Migration], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentOutOfRangeException,Add-Migration


What do I wrong?




[ad_2]

لینک منبع