Question

I have been struggling with the new ASP.NET Identity trying to extend it to do my next web application, I have opend a new empty web project in Visual Studio 2013 Profissional, and added MVC 5 assembly as usual.

I have write the following in VB.NET (Code-First)

Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema
Imports Microsoft.AspNet.Identity.EntityFramework
Imports System.Data.Entity

Partial Public Class MyAppContext
    Inherits IdentityDbContext(Of User)

    Public Sub New()
        MyBase.New("ConnStr")
    End Sub

    Public Overridable Property Items As DbSet(Of Item)
End Class

Partial Public Class User
    Inherits IdentityUser

    <Required>
    Public Property Name As String

    Public Property Items As ICollection(Of Item) = New HashSet(Of Item)

End Class

Partial Public Class Item
    <Key> <DatabaseGenerated(DatabaseGeneratedOption.Identity)>
    Public Property ID As Integer

    <Required>
    Public Property Name As String

    <Required>
    Public Property UserID As String

    <ForeignKey("UserID")>
    Public Overridable Property User As User
End Class

I think the code is very straight-forward, i am trying to create "User" class that inherit from "IdentityUser" and adding a one-to-many relationship with another class called "Item", and of course I have to extend the generic class "IdentityDbContext(Of User)".

Then I want to add a controller with the views for my "User" and "Item" classes using the scaffolding option "MVC 5 Controller with views, using Entity Framework".

MVC 5 Controller with views, using Entity Framework

Scaffolding Error

Error There was an error running the selected code generator: 'Value cannot be null. Parameter name: codeType'

I want you to know that this is a clean setup for visual studio 2013, a clean project, and also the scaffolding works very good for the current model without the Identity inheritance thing.

Please let me know if you have successfully reproduce the problem on your machines.

Was it helpful?

Solution

I wanted to let you know that after i have converted the exact code to C# it worked!...

It seems that this is a vb.net related problem (something with the built-in t4 templetes).

So this is a bug, and i will assume this is the answer.

If somebody found a workaround for this, please post and I will accept it as the answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top