Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Trying MVC on simple examples I've faced a problem with creating templated controller with reading and writing and views using Entity Framework.

I choose model class Album.cs
C#
public class Album
{
    public int AlbumId { get; set; }
    public int GenreId { get; set; }
    public int ArtistId { get; set; }
    public string Title { get; set; }
    public decimal Price { get; set; }
    public string AlbumArtUrl { get; set; }
    public Genre Genre { get; set; }
}

My data context is MusicStoreEntities:
C#
public class MusicStoreEntities : DbContext
{
    public DbSet<Album> Albums { get; set; }
    public DbSet<Genre> Genres { get; set; }
}

The class Genres is
C#
public class Genre
{
    public int GenreId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public List<Album> Albums { get; set; }
}

The problem is that when I press the button "Add" in the dialog of adding new controller, the IDE throws th message-box with the text "Unable to restore metadata for (models_namespace).Album. 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".

Please, help to understand what's the problem and what it wants from me.

I use EF version 5 and MVC 4.</pre>
Posted
Comments
Nathan Minier 14-Nov-14 7:37am    
Do you have a connection string setup for MusicStoreEntites in your web config, that explicitly targets a specific DB provider?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900