首页

code first migration

c#

2020-9-10

code first migration programm,根据代码自动生成了数据库表以及相关数据

using CodeFirstDemo.Migrations;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeFirstDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<BlogContext, Configuration>());
            using (var db = new BlogContext())
            {
                db.Blogs.Add(new Blog { Name = "Another Blog" });
                db.SaveChanges();

                foreach (var blog in db.Blogs)
                {
                    Console.WriteLine(blog.Name);
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
}
资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
.vs/CodeFirstDemo/v15/.suo , 61440
.vs/CodeFirstDemo/v15/Server/sqlite3/storage.ide , 4096
.vs/CodeFirstDemo/v15/Server/sqlite3/storage.ide-shm , 32768
.vs/CodeFirstDemo/v15/Server/sqlite3/storage.ide-wal , 3081792
CodeFirstDemo/App.config , 1340
CodeFirstDemo/Blog.cs , 481
CodeFirstDemo/BlogContext.cs , 416
CodeFirstDemo/CodeFirstDemo.csproj , 6146
CodeFirstDemo/Migrations/202001312251078_InitialCreate.Designer.cs , 850
CodeFirstDemo/Migrations/202001312251078_InitialCreate.cs , 649
CodeFirstDemo/Migrations/202001312251078_InitialCreate.resx , 7261
CodeFirstDemo/Migrations/202001312308015_AddBlogUrl.Designer.cs , 841
CodeFirstDemo/Migrations/202001312308015_AddBlogUrl.cs , 409
CodeFirstDemo/Migrations/202001312308015_AddBlogUrl.resx , 7261
CodeFirstDemo/Migrations/202001312315171_AddPostClass.Designer.cs , 847
CodeFirstDemo/Migrations/202001312315171_AddPostClass.cs , 1324
CodeFirstDemo/Migrations/202001312315171_AddPostClass.resx , 7889
CodeFirstDemo/Migrations/202001312321446_AddPostAbstract.Designer.cs , 856
CodeFirstDemo/Migrations/202001312321446_AddPostAbstract.cs , 519
CodeFirstDemo/Migrations/202001312321446_AddPostAbstract.resx , 7917
CodeFirstDemo/Migrations/Configuration.cs , 749
CodeFirstDemo/Post.cs , 522
CodeFirstDemo/Program.cs , 830
CodeFirstDemo/Properties/AssemblyInfo.cs , 1556
CodeFirstDemo/bin/Debug/CodeFirstDemo.exe , 24064
CodeFirstDemo/bin/Debug/CodeFirstDemo.exe.config , 1340
CodeFirstDemo/bin/Debug/CodeFirstDemo.pdb , 62976
CodeFirstDemo/bin/Debug/EntityFramework.SqlServer.dll , 591968
CodeFirstDemo/bin/Debug/EntityFramework.SqlServer.xml , 163193
CodeFirstDemo/bin/Debug/EntityFramework.dll , 4994632
CodeFirstDemo/bin/Debug/EntityFramework.xml , 3738289
CodeFirstDemo/obj/Debug/3qjxc3pu.sql , 12407
CodeFirstDemo/obj/Debug/CodeFirstDemo.Migrations.AddBlogUrl.resources , 1532
CodeFirstDemo/obj/Debug/CodeFirstDemo.Migrations.AddPostAbstract.resources , 2188
CodeFirstDemo/obj/Debug/CodeFirstDemo.Migrations.AddPostClass.resources , 2160
CodeFirstDemo/obj/Debug/CodeFirstDemo.Migrations.InitialCreate.resources , 1532
CodeFirstDemo/obj/Debug/CodeFirstDemo.csproj.CopyComplete , 0
CodeFirstDemo/obj/Debug/CodeFirstDemo.csproj.CoreCompileInputs.cache , 42
CodeFirstDemo/obj/Debug/CodeFirstDemo.csproj.FileListAbsolute.txt , 1586
CodeFirstDemo/obj/Debug/CodeFirstDemo.csproj.GenerateResource.cache , 1156
CodeFirstDemo/obj/Debug/CodeFirstDemo.csprojAssemblyReference.cache , 33981
CodeFirstDemo/obj/Debug/CodeFirstDemo.exe , 24064
CodeFirstDemo/obj/Debug/CodeFirstDemo.pdb , 62976
CodeFirstDemo/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 7229
CodeFirstDemo/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs , 0
CodeFirstDemo/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs , 0
CodeFirstDemo/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs , 0
CodeFirstDemo/packages.config , 143
CodeFirstDemo.sln , 1137
packages/EntityFramework.6.4.0/.signature.p7s , 18711
packages/EntityFramework.6.4.0/EntityFramework.6.4.0.nupkg , 6394929
packages/EntityFramework.6.4.0/build/EntityFramework.DefaultItems.props , 304
packages/EntityFramework.6.4.0/build/EntityFramework.props , 188
packages/EntityFramework.6.4.0/build/EntityFramework.targets , 6671
packages/EntityFramework.6.4.0/build/Microsoft.Data.Entity.Build.Tasks.dll , 31816
packages/EntityFramework.6.4.0/build/netcoreapp3.0/EntityFramework.props , 252
packages/EntityFramework.6.4.0/build/netcoreapp3.0/EntityFramework.targets , 134
packages/EntityFramework.6.4.0/buildTransitive/EntityFramework.props , 138
packages/EntityFramework.6.4.0/buildTransitive/EntityFramework.targets , 140
packages/EntityFramework.6.4.0/buildTransitive/netcoreapp3.0/EntityFramework.props , 155
packages/EntityFramework.6.4.0/buildTransitive/netcoreapp3.0/EntityFramework.targets , 157
packages/EntityFramework.6.4.0/content/net40/App.config.install.xdt , 850
packages/EntityFramework.6.4.0/content/net40/App.config.transform , 209
packages/EntityFramework.6.4.0/content/net40/Web.config.install.xdt , 850
packages/EntityFramework.6.4.0/content/net40/Web.config.transform , 209
packages/EntityFramework.6.4.0/lib/net40/EntityFramework.SqlServer.dll , 586824
packages/EntityFramework.6.4.0/lib/net40/EntityFramework.SqlServer.xml , 153748
packages/EntityFramework.6.4.0/lib/net40/EntityFramework.dll , 4777032
packages/EntityFramework.6.4.0/lib/net40/EntityFramework.xml , 3313592
packages/EntityFramework.6.4.0/lib/net45/EntityFramework.SqlServer.dll , 591968
packages/EntityFramework.6.4.0/lib/net45/EntityFramework.SqlServer.xml , 163193
packages/EntityFramework.6.4.0/lib/net45/EntityFramework.dll , 4994632
packages/EntityFramework.6.4.0/lib/net45/EntityFramework.xml , 3738289
packages/EntityFramework.6.4.0/lib/netstandard2.1/EntityFramework.SqlServer.dll , 591432
packages/EntityFramework.6.4.0/lib/netstandard2.1/EntityFramework.SqlServer.xml , 163193
packages/EntityFramework.6.4.0/lib/netstandard2.1/EntityFramework.dll , 4980808
packages/EntityFramework.6.4.0/lib/netstandard2.1/EntityFramework.xml , 3727602
packages/EntityFramework.6.4.0/tools/EntityFramework6.PS2.psd1 , 15874
packages/EntityFramework.6.4.0/tools/EntityFramework6.PS2.psm1 , 33212
packages/EntityFramework.6.4.0/tools/EntityFramework6.psd1 , 17371
packages/EntityFramework.6.4.0/tools/EntityFramework6.psm1 , 53849
packages/EntityFramework.6.4.0/tools/about_EntityFramework6.help.txt , 1924
packages/EntityFramework.6.4.0/tools/init.ps1 , 13993
packages/EntityFramework.6.4.0/tools/install.ps1 , 14318
packages/EntityFramework.6.4.0/tools/net40/any/ef6.exe , 77888
packages/EntityFramework.6.4.0/tools/net40/any/ef6.pdb , 18680
packages/EntityFramework.6.4.0/tools/net40/win-x86/ef6.exe , 77888
packages/EntityFramework.6.4.0/tools/net40/win-x86/ef6.pdb , 18680
packages/EntityFramework.6.4.0/tools/net45/any/ef6.exe , 78400
packages/EntityFramework.6.4.0/tools/net45/any/ef6.pdb , 18688
packages/EntityFramework.6.4.0/tools/net45/win-x86/ef6.exe , 78400
packages/EntityFramework.6.4.0/tools/net45/win-x86/ef6.pdb , 18688
packages/EntityFramework.6.4.0/tools/netcoreapp3.0/any/ef6.dll , 89672
packages/EntityFramework.6.4.0/tools/netcoreapp3.0/any/ef6.pdb , 19192
packages/EntityFramework.6.4.0/tools/netcoreapp3.0/any/ef6.runtimeconfig.json , 167
没有账号? 忘记密码?

社交账号快速登录