I’m trying to make Scaffold in visual studio with MVC 5 but is giving the following error

Asked

Viewed 41 times

0

I’m trying and makes the following mistake inserir a descrição da imagem aqui

This is the mistake There was an error running the Selected code Generator: 'Unable to Retrieve Metadata for 'iceguara.Models.Member'. Using the same Dbcompilemodel to create contexts Against Different types of database Servers is not supported. Instead, create a separaete dbCompileModel for each type of server being used.

The context is like this

using MySql.Data.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;

namespace iceguara.Models
{
    [DbConfigurationType(typeof(MySqlEFConfiguration))]
    public class Context : DbContext
    {
        public Context() : base("iceguara")
        {
            Configuration.ProxyCreationEnabled = false;
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<Context>());
        }
        public DbSet<Estado> Estados { get; set; }
        //public DbSet<Membro> Membros { get; set; } (Herança de pessoa)
        public DbSet<Pessoa> Pessoas { get; set; }
        //public DbSet<Transporte> Transportes { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove();
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }


    }
}

The class I’m trying to do is this : MEMBER

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace iceguara.Models
{
    public class Membro:Pessoa
    {
        [Required(ErrorMessage = "Preencha o CPF")]
        [DisplayName("CPF")]
        [StringLength(14, MinimumLength = 14, ErrorMessage = "CPF deve ter 14 caracteres.")]
        public string CPF { get; set; }

        [Required(ErrorMessage = "Preencha o telefone")]
        [DisplayName("Telefone")]
        [StringLength(13, MinimumLength = 13, ErrorMessage = "O telefone deve ter 13 caracteres.")]
        public string Telefone { get; set; }

        [Required(ErrorMessage = "Preencha o celular")]
        [DisplayName("Celular")]
        [StringLength(14, MinimumLength = 14, ErrorMessage = "O celular deve ter 14 caracteres.")]
        public string Celular { get; set; }

        [Required(ErrorMessage = "Preencha a Rua")]
        [DisplayName("Rua")]
        [StringLength(14, MinimumLength = 14, ErrorMessage = "O celular deve ter 14 caracteres.")]
        public string Rua { get; set; }

        [Required(ErrorMessage = "Preencha o Bairro")]
        [DisplayName("Bairro")]
        [StringLength(14, MinimumLength = 14, ErrorMessage = "O celular deve ter 14 caracteres.")]
        public string Bairro { get; set; }

        [Required(ErrorMessage = "Preencha Numero da sua casa")]
        [DisplayName("Numero Casa")]
        [StringLength(14, MinimumLength = 14, ErrorMessage = "O celular deve ter 14 caracteres.")]
        public string NumeroCasa { get; set; }

    }
}
  • 1

    Please post the error text-based instead of using image

  • put, sorry, I thought the print would be easier

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.