Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

InvalidOperationException: The entity type myModel requires a primary key to be defined

18.02.2021 (👁5534)

An unhandled exception occurred while processing the request

 

InvalidOperationException: The entity type 'myModel' requires a primary key to be defined. If you intended to use a keyless entity type , call 'HasNoKey' in OnModelCreating

Keyless entity types

Lösung:

Wort [Key] vor die ID der Tablelle einfügen

 

        [Key]

        public int Idcontent { get; set; }

 

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

#nullable disable

namespace CodeDocu.Models

{

    public partial class ContentModel

    {

        //-------------< Class: Model_Project >-------------

        #region Variables

        //------------< Region: Variables >------------

        //[Required]

        [Key]

        public int Idcontent { get; set; }

        public string Title { get; set; }

        public string TextContent { get; set; }

        public string HtmlContent { get; set; }

        public string Folder { get; set; }

        public string Keywords { get; set; }