工具:dbeaver
導出數據結構,注意guid會被解讀成varchar16,需要手動改爲varchar36
mysql中沒有getdate()默認值函數,
需要手動建立外鍵,主鍵,自增
把項目中的地址改爲mysql的,注意數據庫類型
重新用mysql數據庫生成本地model
------*_*------
新方法:文檔 手工同步實體結構:https://freesql.net/guide/code-first.html#%E6%89%8B%E5%B7%A5%E5%90%8C%E6%AD%A5%E5%AE%9E%E4%BD%93%E7%BB%93%E6%9E%84
IEntity用隨便一個表名就可以,命名空間修改爲自己的,DisableSyncStructure改爲false
public static Type[] GetTypesByNameSpace() { List<Type> tableAssembies = new List<Type>(); List<string> entitiesFullName = new List<string>() { "LinCms.Entities.Settings", "LinCms.Entities.Base", }; foreach (Type type in Assembly.GetAssembly(typeof(IEntity)).GetExportedTypes()) foreach (var fullname in entitiesFullName) if (type.FullName.StartsWith(fullname) && type.IsClass) tableAssembies.Add(type); return tableAssembies.ToArray(); }
FSqlHelper.fsql.CodeFirst.SyncStructure(FSqlHelper. GetTypesByNameSpace());
有了數據庫結果,使用dbeaver的數據導出功能
還需要手動配置導航屬性
再使用FreeSql.Generator 生成實體
總結:可以的話不用約束設計,使用char36代替guid