EF 5 Enable-Migrations : No context type was found in the assembly

后端 未结 24 2014
野的像风
野的像风 2020-12-02 11:51

I have 4 projects :

Toombu.Entities : all models are there
Toombu.DataAccess: Mapping, Repository and ToombuContext
Toombu.Logique : Logic of my application         


        
24条回答
  •  独厮守ぢ
    2020-12-02 12:45

    My problem was link----> problem1

    I solved that problem with one simple command line

    Install-Package EntityFramework-IncludePrerelease
    

    After that, i needed to face with one more problem, something like:

    "No context type was found in assembly"

    I solve this really easy. This "No context" that mean you need to create class in "Model" folder in your app with suffix like DbContext ... like this MyDbContext. There you need to include some library using System.Data.Entity;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data.Entity;
    
    
    namespace Oceans.Models
    {
        public class MyDbContext:DbContext
        {
            public MyDbContext()
            {
            }
        }
    }
    

    After that,i just needed this command line:

    Enable-Migrations -ProjectName  -ContextTypeName 
    

提交回复
热议问题