I am using Entity Framework Core 2.0 and SQL Server 2016. I have a .cs class model that maps the SQL Server tables. I am able to insert long string in SQL Server text column, but I am not able to get that column with this model, it returns null with an error:
Object reference object reference not set to instance of object
Model property that holds data is type of string. Any ideas how to map a SQL Server text column with Entity Framework Core 2.0?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>(eb =>
{
eb.Property(b => b.Url).HasColumnType("ntext");
eb.Property(b => b.ModernUrl).HasColumnType("nvarchar(MAX)");
});
}
https://docs.microsoft.com/en-us/ef/core/modeling/relational/data-types