MVC Scaffolding Help

Hi All,

I have an entity framework Db Model being held in one solution (project1) a class library and the MVC website (using Identity) held in a second (project2). I have added the reference of project1 to project2. Now I know the connection to the (MySQL by the way) db is working, as I can compile project2 and register a new user using the default layout provided.

I now want to scaffold our some of the CRUD views, etc. But unfortunately I'm having some issues. Heres what I have done;

I right click on project2 and add new scaffolded Item. (In this case I am trying to add the ability to add roles to the Identity model).

I select 'MVC 5 controller with views, using entity framework'.

I then call the controller RolesController.

I select the AspNetRoles table from project1.

If i select the connection string from the MVC project (this is the extending the IdentityDbContext in project2 Models) which is held in the web.config file. I get the following error;

Error

There was an error running the selected code generator:

'There was an error in compilation of the type 'GetTalent.Models.ApplicationDbContext'.

CS0246: The type or namespace name 'ApplicationUser' could not be found (are you missing a using directive or an assembly reference?)'

Open in new window


Now ApplicationUser does exist in this namespace. Here is the full IdentityModel.cs

namespace GetTalent.Models
{
    public class ApplicationUser : IdentityUser
    {
    }

    [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("AshtonMediaDb")
        {
        }
    }
}

Open in new window


However I use the connection from the app.config in the class library of (project1 DbContext) i get the following error;

There was an error running the selected code generator:

'Unable to retrieve metadata for 'EntityFrameworkDb.AspNetRole'. Using the same DbCompiledModel to create contexts against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.'

Open in new window


any ideas whats going on here?
flynnyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
What is the difference between the connection strings (without private information included)?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
flynnyAuthor Commented:
nothing they are exactly the same.

one is in te class library for the entity class library to build from and the other is just in the MVC project for runtime.
0
Bob LearnedCommented:
How are you passing in the connection string to the data context?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.