Home > front end >  Entity class must be annotated with @Entity kotlin
Entity class must be annotated with @Entity kotlin

Time:11-09

i have issues in the room database i am not understand what is hill is happy i am face error in kotlin please help me out if anyone know the problems

CodePudding user response:

The error is quite clear, you must add @Entity annotation to your User class like this

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity
data class User(@PrimaryKey val id: Long, val name: String)

CodePudding user response:

import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey

@Entity
data class User(
    @PrimaryKey(autoGenerate = true)
    val id: Int,
    val name: String?
)
  • Related