VS 2015 ASP.NET Web API (EF6) & Xamarin Enable-Migrations fails

一曲冷凌霜 提交于 2019-12-04 00:21:23
Francesc Castells

It seems it's complaining about Using StartUp project 'MyProject.App' but you have already specified the start up project name with -StartupProjectName MyProject.App

Can you try only:

Enable-Migrations -enableautomaticmigrations -ContextTypeName MyProject.Models.ApplicationDbContext -ProjectName MyProject -StartupProjectName MyProject.App -Verbose

Make sure that in your start up project config file you have a valid connection string (unless you specify a connection string name in the DbContext constructor, your connection string should be called ApplicationDbContext, like your DbContext, if I remember correctly)


UPDATE I underestimated the problem. It seems it might be not how you specify the start up project, but the start up project itself. I suggest looking at this answer. Pay special attention, as I was saying before, that the connection string exists in the web or app.config in the start up project and has the right name.

Well according to this (tested and works), the only way to enable migrations in aspnetcore+ef6 project, is to have the DbContext impl in an external full .NET class library, plus adding a dummy start up project.
Sucks but works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!