MapSingleType Error

I create an MVC3 project and first use EFCode for the DataAccess layer.

in my database I have a PackaginInfo table, and in project class I, this is my code:

public class Package
{
    public decimal PackageID { get; set; }
    public decimal Title { get; set; }
    public decimal Cost { get; set; }
    public bool isFree { get; set; }

}


public class ParandShopsEntities : DbContext
{       

    protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Package>().MapSingleType().ToTable("PackagingInfo"); 

    }

    public DbSet<Package> PackagingInfo { get; set; }
}

when I debug my project, I get the error: Error System.Data.Entity.ModelConfiguration.EntityTypeConfiguration 'does not contain a definition for "MapSingleType" and does not use the extension method "MapSingleType", which takes the first argument of the type "System.Data.Entity.ModelConfiguration. EntityTypeConfiguration "(can you find missing using directive or assembly reference?) E: \ Projects \ ein co \ 89-11-23 \ Parand \ MvcApplication1 \ Models \ ParandShopsEntities.cs

you are welcome. help me

+3
source share
3 answers

CTP5

modelBuilder.Entity<Package>().ToTable("PackagingInfo"); 
+8

, , TableAttribute:

[Table("PackagingInfo")]
public class Package
{
    public decimal PackageID { get; set; }
    public decimal Title { get; set; }
    public decimal Cost { get; set; }
    public bool isFree { get; set; }
} 
+3

Another thing to check is that you rebuilt all the t4 templates. If you change the navigation properties in the edmx file, you need to rebuild your t4 templates, otherwise you may get this error.

+1
source

Source: https://habr.com/ru/post/1791726/


All Articles