7

I have Demo solution with two projects like this :

enter image description here

I have installed T4Scaffolding.Install-Package T4Scaffolding

I have added a reference of AdventureWorksModel to my RepoLayer Project and install EF6 .


Now when i try to run the following command :

scaffold repository AdventureWorksModel.Customer to my RepoLayer Project

I get the following exception :

Get-ProjectType : Cannot find a type matching the name
'AdventureWorksModel.Customer'. Try specifying the fully-qualified
type name, including namespace.`

although the same command works successfully when i run it on AdventureWorksModel project !

Fabian N.
  • 3,807
  • 2
  • 23
  • 46
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

1 Answers1

3

Here is the steps which you need to do

  1. Class library having AdventureWorksModel EDMX (already present)
  2. Class library "RepoLayer" which above AdventureWorksModel library, EF 6 installed (already present)
  3. In the "RepoLayer" library, please T4Scaffolding.Core.VS2015 and T4Scaffolding.VS2015 NuGet packages. I hope your using VS 2015
  4. Run the scaffolding command scaffold repository AdvwrksModel.Customer for "RepoLayer" library. The repository and DbContext class gets created successfully. Here is screenshot

T4 Scaffolding

Update related to EDMX name from above screen shot The command

scaffold repository AdvwrksModel.Customer

gives us important thought "AdvwrksModel" is EDMX name and namespace should be "AdvwrksModel". Then it will work fine.

From code link provided; After building, it gave same error what you mentioned in question, then after investigation it was namespace issue. Attaching screenshot with points 1, 2, 3, 4 should be "SledModel" i.e. EDMX name. Point 5 is generated repository for Race

I guess this will solve your problem. I am not sure how the namespace was different then EDMX name.

Update EDMX Name

Mithun Pattankar
  • 1,372
  • 1
  • 8
  • 12
  • i use visual studio 2013 – Anyname Donotcare Feb 03 '16 at 18:53
  • 1
    I used VS 2013 version, ensure that T4Scaffolding and T4Scaffolding.Core have latest version installed from NuGet. I was able to creare repository classes for Customer, Product ... I tried against .NET 4.5 . I tried against .NET 4.0 also, it works properly, maybe if can update T4Scaffolding latest version, they might work. – Mithun Pattankar Feb 03 '16 at 21:22
  • I run this command `Install-Package T4Scaffolding` on Package Manage Console , making the default project `RepoLayer` – Anyname Donotcare Feb 04 '16 at 11:58
  • try adding them using NuGet T4Scaffolding & T4Scaffolding.Core instead of console. – Mithun Pattankar Feb 04 '16 at 16:07
  • I have added `T4Scaffolding.Core.VS2015 and T4Scaffolding.VS2015 ` through the `Nuget` but invain !! ,when i try to run `scaffold repository AdventureWorksModel.Customer` and make the `AdventureWorksModel` the Default project instead of `RepoLayer` it works perfectly !! Could you tell me What 's the wrong i made please? – Anyname Donotcare Feb 05 '16 at 11:00
  • The same problem when i use `code first` rather than `DB First` . It works when i run the command on the `domain classes` and failed with `data layer` !! – Anyname Donotcare Feb 06 '16 at 11:27
  • Can you share the project soln with me? I have a look on that. Running fine on domain classes is very natural but on data layer also it should work. – Mithun Pattankar Feb 06 '16 at 15:06
  • I have try another small project with the same error :Here 's the link : https://www.dropbox.com/s/0lf2msjeyq5qnor/SledDogEvent.rar?dl=0 – Anyname Donotcare Feb 06 '16 at 17:07
  • i use V.S 2013 ,Really grateful for you. – Anyname Donotcare Feb 06 '16 at 17:08
  • Have a look at updated solution link. I used VS 2013 and also I have updated my answer for more details. https://www.dropbox.com/s/8w4abc7pq4ligqf/SledDog-Fixed.zip?dl=0 – Mithun Pattankar Feb 06 '16 at 21:00