听说 SQL Server Compact Edition 4.0 CTP 中修复了这个问题
最近刚接触SQL Server CE和Entity Framework,VS2010还不支持SQL Server CE 4.0
我想我需要解决这个问题
我能知道如何在实体对象的构造函数中生成一个整数类型的身份主键
public partial class Book
{
public Book()
{
// SQL Server Compact does not support entities with server-generated keys or values when it is used
// with the Entity Framework. Therefore, we need to create the keys ourselves.
Id = // Generating a Integer Identity Id here
//similar to Guid.NewGuid();
}
}
非常感谢您的帮助。
最佳答案
我已经将 VS2010 和 SQL Server CE 与 Entity Framework CTP4 Code-First 一起使用,并且没有任何问题。我已经使用 NuPack(现在是 NuGet - http://nuget.codeplex.com/)安装了这两个东西,并将其与 ASP.NET MVC 3 Beta 应用程序一起使用。
NuGet 上最新版本的 SQLCE 是 4.0.8435.1,要将它与 EF 一起使用,您需要 SQLCE.EntityFramework 4.0.8435.1。
关于c# - 在 Entity Framework 和 SQL Server CE 中为实体对象生成整数标识主键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3739304/