You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Chapter 10 "Working with Data Using Entity Framework Core", I see Course.cs define Title with string length 60.
Course.cs
using System.ComponentModel.DataAnnotations;
namespace CoursesAndStudents;
public class Course
{
public int CourseId { get; set; }
[Required]
[StringLength(60)]
public string? Title { get; set; }
public ICollection<Student>? Students { get; set; }
}
However, the generated SQL script appears to not honor StringLength attribute, nor MaxLength attribute, when building SQL for SQLite3.
Using C:\Code\Chapter10\CoursesAndStudents\bin\Debug\net6.0\Academy.db database file.
Database deleted: False
Database created: True
SQL script used to create database:
CREATE TABLE "Courses" (
"CourseId" INTEGER NOT NULL CONSTRAINT "PK_Courses" PRIMARY KEY AUTOINCREMENT,
"Title" TEXT NOT NULL
);
...
Q) Any thoughts, on why [StringLength(60)] is not applied to the schema?
In Chapter 10 "Working with Data Using Entity Framework Core", I see
Course.cs
defineTitle
with string length 60.Course.cs
However, the generated SQL script appears to not honor
StringLength
attribute, norMaxLength
attribute, when building SQL for SQLite3.Q) Any thoughts, on why
[StringLength(60)]
is not applied to the schema?Thanks in advance @markjprice!
Playing Around
Playing around I learned that the
Column
attribute does work however!Success:
The text was updated successfully, but these errors were encountered: