SubSonic3 - 列“CategoryID”不能为空
我将 Subsonic 与 SimpleRepository 一起使用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.DataProviders;
using SubSonic.Repository;
namespace SubSonicTest
{
class Program
{
public class Product
{
public int ProductID { get; set; }
public int CategoryID { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public bool Discontinued { get; set; }
}
static void Main(string[] args)
{
var repo = new SimpleRepository("SubSonic", SimpleRepositoryOptions.RunMigrations);
var newProduct = new Product();
newProduct.CategoryID = 5;
newProduct.ProductName = "Pretzel";
newProduct.UnitPrice = 100;
newProduct.Discontinued = false;
repo.Add<Product>(newProduct);
}
}
}
但是,当我运行此命令时,我得到: 列“CategoryID”不能为空 这是 MySQL 和 Windows 以及 VS2008 的情况。有什么想法吗?
谢谢
I'm using Subsonic with SimpleRepository:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.DataProviders;
using SubSonic.Repository;
namespace SubSonicTest
{
class Program
{
public class Product
{
public int ProductID { get; set; }
public int CategoryID { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public bool Discontinued { get; set; }
}
static void Main(string[] args)
{
var repo = new SimpleRepository("SubSonic", SimpleRepositoryOptions.RunMigrations);
var newProduct = new Product();
newProduct.CategoryID = 5;
newProduct.ProductName = "Pretzel";
newProduct.UnitPrice = 100;
newProduct.Discontinued = false;
repo.Add<Product>(newProduct);
}
}
}
However, when I run this, I get: Column 'CategoryID' cannot be null
This is with MySQL and windows and VS2008. Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试改变你的类属性定义;
不能将 int 类型设置为 null。
Try changing your class property definition;
You cant set the int type to null.