I am trying to run the application using Mono. It works fine on IIS, but I want it to work on Mono. But it always throws it to me:
The "CreateDate" property in "Article" cannot be set to "System.String". You must set this property to a non-zero value of type "System.DateTime".
The fact is that the place where it was chosen is as follows:
public Article[] Select(int number)
{
return DbContextProvider.Current.Set<Article>()
.OrderByDescending(n => n.CreateDate)
.Take(number)
.ToArray();
}
Nothing is used by System.String. In fact, the only place it converts to a string is here:
@using BaseSite.Extensions.DateTimeExtensions
@model Classic.Views.Home.Articles.ArticleViewModel
<div class="article-wrapper">
<div class="article-title">
@Html.ActionLink(Model.Title, "Index", "Articles", new RouteValueDictionary{{"articleId", Model.ArticleId}}, null)
</div>
@Html.Raw(Model.Text)
<div class="article-data date">
@Html.ActionLink(Model.UserId, "Index", "Profile", new RouteValueDictionary{{"userId", Model.UserId}}, null),
@Model.CreateDate.Format(true)
</div>
</div>
But before that there is an error. And it works on IIS, only on Mono there is such a strange error.
Database table table:
CREATE TABLE [dbo].[Articles](
[ArticleId] [uniqueidentifier] NOT NULL,
[UserId] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreateDate] [datetime2](7) NOT NULL,
[Title] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Text] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
PRIMARY KEY CLUSTERED
(
[ArticleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Display Classes:
using System;
namespace BusinessObjects.Articles
{
public class Article
{
public Guid ArticleId { get; set; }
public string UserId { get; set; }
public DateTime CreateDate { get; set; }
public string Title { get; set; }
public string Text { get; set; }
}
}
using System.Data.Entity;
namespace BusinessObjects.Articles
{
public class ArticleMapper : IDbMapper
{
public void Map(DbModelBuilder modelBuilder)
{
var entity = modelBuilder.Entity<Article>();
entity.HasKey(n => n.ArticleId);
entity.Property(n => n.ArticleId).IsRequired();
entity.Property(n => n.UserId).IsRequired().HasMaxLength(30);
entity.Property(n => n.Title).IsRequired().HasMaxLength(50);
entity.Property(n => n.Text).IsRequired().IsMaxLength();
}
}
}
. DateTime, . IIS (MS Stack), Mono + xsp4.
- ? .
PS: , Mono git master 3.8.1 (master/38c3874), 3.6, 3.2.8 ..