Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add migration failed if DbContext in sperate project #2358

Closed
cuiliang opened this issue Jun 10, 2015 · 2 comments
Closed

add migration failed if DbContext in sperate project #2358

cuiliang opened this issue Jun 10, 2015 · 2 comments

Comments

@cuiliang
Copy link

I have a DAL project to hold EntityFramework stuff.
When run dnx . ef migration add changecolumn under DAL project, result will be:

Using context 'ApplicationDbContext'.
System.InvalidOperationException: A type named 'StartupProduction' or 'Startup' could not be found in assembly
'Itemz.DAL'.
   在 Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String startupAssemblyName, IList`1 diagno
sticMessages)
   在 Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup()
   在 Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
   在 Microsoft.AspNet.Hosting.Internal.HostingEngine.get_ApplicationServices()
   在 Microsoft.Data.Entity.Commands.ContextTool.TryCreateContextFromStartup(Type type, String startupAssemblyN
ame)
   在 Microsoft.Data.Entity.Commands.ContextTool.CreateContext(Type type, String startupAssemblyName)
   在 Microsoft.Data.Entity.Commands.MigrationTool.CreateContext(Type type, String startupAssemblyName)
   在 Microsoft.Data.Entity.Commands.MigrationTool.AddMigration(String migrationName, String contextTypeName, S
tring startupAssemblyName, String rootNamespace, String projectDir)
   在 Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass11_0.<AddMigration>b__0()
   在 Microsoft.Data.Entity.Commands.Program.Execute(String startupProject, Func`1 invoke)
   在 Microsoft.Data.Entity.Commands.Program.AddMigration(String name, String context, String startupProject)
   在 Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass9_1.<Main>b__6()
   在 Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
   在 Microsoft.Data.Entity.Commands.Program.Main(String[] args)
.....

If run dnx . ef migration add changecolumn command under Web project which referenced DAL project, the result will be:
···
System.InvalidOperationException: No DbContext was found. Ensure that you're using the correct assembly and tha
t the type is neither abstract nor generic.
在 Microsoft.Data.Entity.Commands.ContextTool.SelectType(IEnumerable1 types, String name) 在 Microsoft.Data.Entity.Commands.MigrationTool.GetContextType(String name) 在 Microsoft.Data.Entity.Commands.MigrationTool.AddMigration(String migrationName, String contextTypeName, S tring startupAssemblyName, String rootNamespace, String projectDir) 在 Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass11_0.<AddMigration>b__0() 在 Microsoft.Data.Entity.Commands.Program.Execute(String startupProject, Func1 invoke)
在 Microsoft.Data.Entity.Commands.Program.AddMigration(String name, String context, String startupProject)
在 Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass9_1.

b__6()
在 Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
在 Microsoft.Data.Entity.Commands.Program.Main(String[] args)
···

@rowanmiller rowanmiller added this to the 7.0.0 milestone Jun 12, 2015
@rowanmiller
Copy link
Contributor

@bricelam assume this is a dupe of something you already have open, so feel free to close with a link to the issue

@bricelam
Copy link
Contributor

bricelam commented Jul 3, 2015

Dupe of #2256 and the higher-level #2294

@bricelam bricelam closed this as completed Jul 3, 2015
@bricelam bricelam removed this from the 7.0.0 milestone Jul 3, 2015
@bricelam bricelam removed their assignment Jul 3, 2015
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants