Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET MVC4+;Mono上的剃须刀&x2B;EF 6日期时间崩溃_C#_Asp.net Mvc 4_Iis_Mono - Fatal编程技术网

C# ASP.NET MVC4+;Mono上的剃须刀&x2B;EF 6日期时间崩溃

C# ASP.NET MVC4+;Mono上的剃须刀&x2B;EF 6日期时间崩溃,c#,asp.net-mvc-4,iis,mono,C#,Asp.net Mvc 4,Iis,Mono,我正在尝试使用Mono运行应用程序。它在IIS上运行良好,但我希望它在Mono上运行。但它总是把这个扔给我: 无法将“Article”上的“CreateDate”属性设置为“System.String”值。必须将此属性设置为“System.DateTime”类型的非空值 事实上,它被扔到的地方是: public Article[] Select(int number) { return DbContextProvider.Current.Set<Ar

我正在尝试使用Mono运行应用程序。它在IIS上运行良好,但我希望它在Mono上运行。但它总是把这个扔给我:

无法将“Article”上的“CreateDate”属性设置为“System.String”值。必须将此属性设置为“System.DateTime”类型的非空值

事实上,它被扔到的地方是:

public Article[] Select(int number)
        {
            return DbContextProvider.Current.Set<Article>()
                .OrderByDescending(n => n.CreateDate)
                .Take(number)
                .ToArray();
        }
映射类:

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();
        }
    }
}
使用系统;
命名空间BusinessObjects.Articles
{
公共类文章
{
公共Guid ArticleId{get;set;}
公共字符串用户标识{get;set;}
公共日期时间CreateDate{get;set;}
公共字符串标题{get;set;}
公共字符串文本{get;set;}
}
}
使用System.Data.Entity;
命名空间BusinessObjects.Articles
{
公共类ArticleMapper:IDbMapper
{
公共void映射(DbModelBuilder modelBuilder)
{
var entity=modelBuilder.entity();
entity.HasKey(n=>n.ArticleId);
Property(n=>n.ArticleId).IsRequired();
entity.Property(n=>n.UserId).IsRequired().HasMaxLength(30);
entity.Property(n=>n.Title).IsRequired().HasMaxLength(50);
Property(n=>n.Text).IsRequired().IsMaxLength();
}
}
}
是的。我还有其他带有DateTime的表,它们都有这个错误。而且它们都在IIS(MS Stack)上正常运行,只在Mono+xsp4上有bug。 有人能提供帮助吗?我被那种古怪迷住了


PS:我尝试了几乎所有的mono版本,现在我是mono git master 3.8.1(master/38c3874),与3.6、3.2.8等版本一样,正如Alexander Köplinger提到的,mono内部似乎存在“datetime2”缺陷。通过从MsSql迁移到PostgreSql修复了此问题-计划中有此问题。

我想我以前在Mono上使用datetime2作为SQL列时遇到过问题,似乎它还不受支持。你能试着删除该列,看看它是否有效吗?啊哈,那么它是Mono bug上的datetime2列?因为我考虑迁移到PgSql,这能帮助吗?它没有DATETME2工作吗?在这种情况下,迁移到PgSql可能会有所帮助,因为我认为它不使用这种类型
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]
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();
        }
    }
}