Class byte for C#Image Storage

Asked

Viewed 34 times

0

I am new in programming I am creating an application for Hotels and in this application we will have several images for each hotel, I created the following code:

public class hotel : BaseClass
    public List<Image> Images { get; set;}

There inside the image.Cs file

public class Image
    public Byte Image {get; get;} 

hotelimage.cd file

public class HotelImage : BaseClass
    public Guid HotelID {get; set;}
    public Hotel Hotels {get; set;}
    public Guid ImageId {get; set;}
    public Image Images {get; set;}

within the context.Cs

modelBuilder.Entity<HotelImage>.HasKey(sc => new { sc.HotelId, sc.ImagemId});

But when generating the BD with the Add-Migration and Update Database it does not create a field to store image. There is something wrong with this code

  • 1

    It would be because the property Image was declared with two get instead of a get and a set?

  • Good, let me update this, ñ had noticed this error, I already return if it worked

  • It didn’t work either, I found another error in my code, public class hotel : Baseclass public List<Image> Images { get; set;} the correct one would be: public class hotel : Baseclass public List<Hotelimage> Images { get; set;} and correction in the context as follows modelBuilder.Entity<Hotelimage>() . Hasrequired(bc => bc.Hotels) . Withmany(b => b.Images) . Hasforeignkey(bc => bc.Hotelid);

No answers

Browser other questions tagged

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