0

I have class with this definition :

public class WebSiteContent 
    {
        public Guid Id { get; set; }
        public About About { get; set; }
        public Tips Tips { get; set; }
        public Images Images { get; set; }
    }

where my About and Tips and Images are look like this :

 public class About
    {
        public Guid Id { get; set; }
        public string Text { get; set; }
        public string Addres { get; set; }
        public int PhoneNumber { get; set; }
        public int Mobile { get; set; }
    }

and Tips :

 public class Tips
    {
        public Guid Guid { get; set; }
        public string Content { get; set; }
    }

and Images :

public class Images
    {
        public Guid Id { get; set; }
        public string Background { get; set; }
        public string Logo { get; set; }
        public About About { get; set; }

    }

here i just want to use about and Images and tips as a helper class to just create a property and don't want to have about,Images or tips table in database !

Entity framework needs Id to map all of above classes , how can I do that ?

1 Answer 1

1

here i just want to use about and Images and tips as a helper class to just create a property and don't want to have about,Images or tips table in database

So you are looking for complex type. Mark your About, Tips and Images classes with [ComplexType] attribute.

Entity framework needs Id to map all of above classes , how can I do that ?

EF only needs Id for entities. If you map them as complex types you will not need to use any Id.

Btw. if you don't want to have those classes and their properties in database at all you can use [NotMapped] attribute instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.