[Entity Framework] Code First @ SQL Compact EF6.1
A few days ago EF6.1 just RTM, EntityFramework.SqlServerCompact also collectively to a 6.1
Preparing the environment
- From the Extensions and Updates download SQL Server Compact Toolbox
- From NuGet EntityFramework.SqlServerCompact 6.1.0 Download
Reference use Code First Part
http://www.dotblogs.com.tw/yc421206/archive/2014/01/20/141712.aspx
Connection String
After completion, dynamically generated data, as shown below:
Up to now not much use on the issues
Next, I want to use reverse-engineer existing DB, turn into Code First program has no built-in VS2013 SQLCE connection management, must rely on SQL Server Compact Toolbox, however, it seems to have SQL Server Compact Toolbox It does not turn into the stencil Code First
Just as feel lost, did not give up to find a SSCEVSTools, you can use it to replace SQL Server Compact Toolbox Management
http://visualstudiogallery.msdn.microsoft.com/df093e9f-3e74-41c5-aeec-6371436423c5
So you can use it to manage the connection SQLCE
Regardless SSCEVSTools really easy to use (with a personal feel bad), finally saw the Server Explorer SQLCE
Then we can take advantage of the new features to create Code First program, refer to Part http://www.dotblogs.com.tw/yc421206/archive/2014/03/18/144430.aspx
Procedure as follows:
Code First created out
{ public Model1() : base("name=Model1") { } public virtual DbSetCustomers { get; set; } public virtual DbSet Products { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity () .HasMany(e => e.Products) .WithOptional(e => e.Customers) .HasForeignKey(e => e.Customer_Id); } }
Connection String
Article from: http: //www.dotblogs.com.tw/yc421206/archive/2014/03/19/144449.aspx
If any error, please notify the novice posting him to bear
2010 ~ 2017 C # in the fourth quarter
Original: Large column [Entity Framework] Code First @ SQL Compact EF6.1