顯示具有 entity framework 標籤的文章。 顯示所有文章
顯示具有 entity framework 標籤的文章。 顯示所有文章

2016年11月10日 星期四

MVC網站使用多個資料庫(Code First)

    下命令時需指定使用哪個DataContext
    -Verbose 可以觀察migration流程

  1. enable-migrations -ContextTypeName MultiDataContextMigrations.Models.DataContext -MigrationsDirectory:DataContextMigrations

  2. Add-Migration -configuration MultiDataContextMigrations.DataContextMigrations.Configuration Initial

  3. Update-Database -configuration MultiDataContextMigrations.DataContextMigrations.Configuration -Verbose

2016年10月5日 星期三

EF with MySQL syntax error 解決辦法

mvc網站對mySql建立entity之後,在新增時出錯 錯誤內容: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near: {SQL COMMAND} 1.Right click on the edmx file, select Open with, XML editor 2.Remove the DefiningQuery entirely 3.Rename the store:Schema="dbo" to Schema="dbo (remove the "store:") 4.Remove the store:Name=... property (entirely)