Multiple item in object












0















c# : EF Relation
.net core
Good Afternoon
I'm trying to create service for Dietician.
I want to made Db that allow :
One diet can have multiple Meal but
one Meal can be at multiple diet
now i has



public class DietList
{
public Guid DietListId { get; set; }
[Display(Name = "Nazwa diety")]
public string DietName { get; set; }

public DateTime AddedDataTime { get; set; }
public string Describe { get; set; }

public List<Meal> MealId { get; set; }
}


and



public class Meal
{
public Guid MealId { get; set; }
[Display(Name = "Nazwa Posiłku")]
public string MealName { get; set; }
[Display(Name = "Typ Posiłku")]
public string MealType { get; set; }
[Display(Name = "Składniki")]
public string Components { get; set; }

public List<DietList> DietListId { get; set; }
}


but it throw exception :
Unable to determine the relationship represented by navigation property 'DietList.MealId' of type 'List'.
Any solve of this problem ?










share|improve this question

























  • is the dotnet core or .Net Framework?

    – Sam
    Nov 22 '18 at 17:33











  • There is not enough info but I think you need to change the names of your navigation property.

    – Llazar
    Nov 22 '18 at 17:34











  • it's a .net core im added information about that

    – Systu
    Nov 22 '18 at 17:36











  • Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

    – Steve Greene
    Nov 22 '18 at 17:38






  • 3





    If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

    – vinicius.ras
    Nov 22 '18 at 18:01
















0















c# : EF Relation
.net core
Good Afternoon
I'm trying to create service for Dietician.
I want to made Db that allow :
One diet can have multiple Meal but
one Meal can be at multiple diet
now i has



public class DietList
{
public Guid DietListId { get; set; }
[Display(Name = "Nazwa diety")]
public string DietName { get; set; }

public DateTime AddedDataTime { get; set; }
public string Describe { get; set; }

public List<Meal> MealId { get; set; }
}


and



public class Meal
{
public Guid MealId { get; set; }
[Display(Name = "Nazwa Posiłku")]
public string MealName { get; set; }
[Display(Name = "Typ Posiłku")]
public string MealType { get; set; }
[Display(Name = "Składniki")]
public string Components { get; set; }

public List<DietList> DietListId { get; set; }
}


but it throw exception :
Unable to determine the relationship represented by navigation property 'DietList.MealId' of type 'List'.
Any solve of this problem ?










share|improve this question

























  • is the dotnet core or .Net Framework?

    – Sam
    Nov 22 '18 at 17:33











  • There is not enough info but I think you need to change the names of your navigation property.

    – Llazar
    Nov 22 '18 at 17:34











  • it's a .net core im added information about that

    – Systu
    Nov 22 '18 at 17:36











  • Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

    – Steve Greene
    Nov 22 '18 at 17:38






  • 3





    If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

    – vinicius.ras
    Nov 22 '18 at 18:01














0












0








0








c# : EF Relation
.net core
Good Afternoon
I'm trying to create service for Dietician.
I want to made Db that allow :
One diet can have multiple Meal but
one Meal can be at multiple diet
now i has



public class DietList
{
public Guid DietListId { get; set; }
[Display(Name = "Nazwa diety")]
public string DietName { get; set; }

public DateTime AddedDataTime { get; set; }
public string Describe { get; set; }

public List<Meal> MealId { get; set; }
}


and



public class Meal
{
public Guid MealId { get; set; }
[Display(Name = "Nazwa Posiłku")]
public string MealName { get; set; }
[Display(Name = "Typ Posiłku")]
public string MealType { get; set; }
[Display(Name = "Składniki")]
public string Components { get; set; }

public List<DietList> DietListId { get; set; }
}


but it throw exception :
Unable to determine the relationship represented by navigation property 'DietList.MealId' of type 'List'.
Any solve of this problem ?










share|improve this question
















c# : EF Relation
.net core
Good Afternoon
I'm trying to create service for Dietician.
I want to made Db that allow :
One diet can have multiple Meal but
one Meal can be at multiple diet
now i has



public class DietList
{
public Guid DietListId { get; set; }
[Display(Name = "Nazwa diety")]
public string DietName { get; set; }

public DateTime AddedDataTime { get; set; }
public string Describe { get; set; }

public List<Meal> MealId { get; set; }
}


and



public class Meal
{
public Guid MealId { get; set; }
[Display(Name = "Nazwa Posiłku")]
public string MealName { get; set; }
[Display(Name = "Typ Posiłku")]
public string MealType { get; set; }
[Display(Name = "Składniki")]
public string Components { get; set; }

public List<DietList> DietListId { get; set; }
}


but it throw exception :
Unable to determine the relationship represented by navigation property 'DietList.MealId' of type 'List'.
Any solve of this problem ?







c# sql database entity-framework asp.net-core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 17:36







Systu

















asked Nov 22 '18 at 17:28









SystuSystu

127




127













  • is the dotnet core or .Net Framework?

    – Sam
    Nov 22 '18 at 17:33











  • There is not enough info but I think you need to change the names of your navigation property.

    – Llazar
    Nov 22 '18 at 17:34











  • it's a .net core im added information about that

    – Systu
    Nov 22 '18 at 17:36











  • Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

    – Steve Greene
    Nov 22 '18 at 17:38






  • 3





    If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

    – vinicius.ras
    Nov 22 '18 at 18:01



















  • is the dotnet core or .Net Framework?

    – Sam
    Nov 22 '18 at 17:33











  • There is not enough info but I think you need to change the names of your navigation property.

    – Llazar
    Nov 22 '18 at 17:34











  • it's a .net core im added information about that

    – Systu
    Nov 22 '18 at 17:36











  • Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

    – Steve Greene
    Nov 22 '18 at 17:38






  • 3





    If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

    – vinicius.ras
    Nov 22 '18 at 18:01

















is the dotnet core or .Net Framework?

– Sam
Nov 22 '18 at 17:33





is the dotnet core or .Net Framework?

– Sam
Nov 22 '18 at 17:33













There is not enough info but I think you need to change the names of your navigation property.

– Llazar
Nov 22 '18 at 17:34





There is not enough info but I think you need to change the names of your navigation property.

– Llazar
Nov 22 '18 at 17:34













it's a .net core im added information about that

– Systu
Nov 22 '18 at 17:36





it's a .net core im added information about that

– Systu
Nov 22 '18 at 17:36













Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

– Steve Greene
Nov 22 '18 at 17:38





Yes, change your names from MealId -> MealList and DietListId -> DietList. That may not be your issue, but it makes it clearer. Also, any fluent code?

– Steve Greene
Nov 22 '18 at 17:38




3




3





If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

– vinicius.ras
Nov 22 '18 at 18:01





If you are using Entity Framework Core, you cannot model Many-to-many relationships without an intermediate table. Read these docs for more information. You would have to create a model class to link your DietList and Meal instances.

– vinicius.ras
Nov 22 '18 at 18:01












1 Answer
1






active

oldest

votes


















3














Based on your description, you have a many-to-many relationship between Diet and Meal.
It needs an extra/middle table to store the linkage of entities, say DietMeals.
Then you can specify the relationship in the DbContext class.



You can refer to this article.





The property naming looks a little bit confusing. The collection name should in plural form, say:



Public List<Meal> Meals { get; set; }





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435851%2fmultiple-item-in-object%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Based on your description, you have a many-to-many relationship between Diet and Meal.
    It needs an extra/middle table to store the linkage of entities, say DietMeals.
    Then you can specify the relationship in the DbContext class.



    You can refer to this article.





    The property naming looks a little bit confusing. The collection name should in plural form, say:



    Public List<Meal> Meals { get; set; }





    share|improve this answer






























      3














      Based on your description, you have a many-to-many relationship between Diet and Meal.
      It needs an extra/middle table to store the linkage of entities, say DietMeals.
      Then you can specify the relationship in the DbContext class.



      You can refer to this article.





      The property naming looks a little bit confusing. The collection name should in plural form, say:



      Public List<Meal> Meals { get; set; }





      share|improve this answer




























        3












        3








        3







        Based on your description, you have a many-to-many relationship between Diet and Meal.
        It needs an extra/middle table to store the linkage of entities, say DietMeals.
        Then you can specify the relationship in the DbContext class.



        You can refer to this article.





        The property naming looks a little bit confusing. The collection name should in plural form, say:



        Public List<Meal> Meals { get; set; }





        share|improve this answer















        Based on your description, you have a many-to-many relationship between Diet and Meal.
        It needs an extra/middle table to store the linkage of entities, say DietMeals.
        Then you can specify the relationship in the DbContext class.



        You can refer to this article.





        The property naming looks a little bit confusing. The collection name should in plural form, say:



        Public List<Meal> Meals { get; set; }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 23 '18 at 2:07









        fuzz

        15.4k17108183




        15.4k17108183










        answered Nov 23 '18 at 1:50









        PegasusPegasus

        463




        463






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435851%2fmultiple-item-in-object%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python