To convert an existing application to the new model, you need to convert the meta-data into the new format (MC# files) and then delete the old meta-data files (.msharp files).
- Open the project in the old M# as before and build everything.
- Open the solution in Visual Studio.
- For all projects in the solution, go to properties window and change it to
.NET 4.7.2 - Update
MSharp.Frameworknuget packages to the latest version - In Website, add the nuget package:
Microsoft.CodeDom.Providers.DotNetCompilerPlatformif it has not been referenced before - Open
web.configand change connection string to useMyProject.Tempas the DB name, and.\SqlExpress - Compile everything.
- In this step, if you get an error related to the enum values, you can simply comment those parts and after adding #Model project you can specify enum values in the
InstanceAccessors(..)method and then uncomment those parts again.
- In this step, if you get an error related to the enum values, you can simply comment those parts and after adding #Model project you can specify enum values in the
- For all projects in the solution, go to properties window and change it to
If your project is WebForms, perhaps your domain model project name is "Model" instead of "Domain". You should change it to "Domain":
- In the project settings in M# IDE, set Model Project Folder to "Domain"
- Visual Studio: Remove the Model project from the solution and save everything.
- Rename the folder from Model to Domain
- Rename the csproj file inside that folder to also Domain
- In Visual Studio, right click on the solution and choose Add > Existing project and select the new
Domain.csprojfile.
- Close the project in IDE
- Copy MSharpTools to your computer.
- Run msharptools.exe "{solutionRoot}" /mcs
- It will create a new folder in the solution named M#. Inside that, it will generate two new folders: Model and UI.
- In Visual Studio, use Add Existing project and add
M#\ModelandM#\UIprojects to the solution.- If
#Model > ProjectSettings.cshas.GeneratedDALFolder("DAL")method, please comment it.
- If
- In Visual Studio, go to Manage Nuget packages and click on the Restore button at the top.
- Sometimes even after restoring nuget packages some of them are not loaded completely, if you experience this issue you should use
Update-Package -reinstallcommand in the Package Manager Console.
- Sometimes even after restoring nuget packages some of them are not loaded completely, if you experience this issue you should use
- In the Domain project, include the newly generated [DEV-SCRIPTS]\ReferenceData.cs
- In
TheApplication.cs(orGlobal.asaxin Web Forms) add the following:
protected override void InitiateApplication()
{
MSharp.Framework.Services.TestDatabaseGenerator.CreateReferenceData = ReferenceData.Create;
base.InitiateApplication();
}- Remove the Entities folder from the Domain project.
- Remove the Mappings or DAL folder from the Domain project.
- Delete the old folder @M# as it's no longer used in the new model.
- NOTE: If you have changed anything in the Manual folder, you should manually move that to the new model.
- In the gitignore file, add M#/lib/
- Also ensure that all obj and bin folders are excluded.
- Update app setting in web.config file of website project:
<add key="M#.Meta.Location" value="C:\Projects\[YOURProjectNAME]\DB" />Depending on your project you may need to add this part too:
<add key="Temp.Databases.Location" value="C:\@Database.Files" />In Visual Studio, compile the following projects in the following order:
- #Model
- Domain
- #UI
- Website
If you faced any problem, please report to Paymon immediately. Otherwise you're good to go.
- Learn to use the M# CLI to diagnose problems
- If your application has an entity named "Project", rename the generated #Model\Project.cs class to "OverallProject".
Also consider the following architectural changes:
| Old M# | The MC# way |
|---|---|
| @M#*.msharp: These json files defined your M# elements such as entity types, pages, modules, etc | The metadata is defined as C# files inside the #Model and #UI projects |
| @M#\Tables*.Create.sql: These files defined your application database schema. When you loaded a project in the M# Agent app, it read the above files and create a database named MyApp.DesignTime from the schema | Entity definitions are enough. Upon building the #Model project, M# will generate the schema of the database into \DB folder. |
| @M#\Tables*.Data.sql: These SQL files contained your reference data. Upon loading a project, these were inserted into the MyApp.DesignTime database. | Reference data is defined as C# code rather than SQL files inside ReferenceData.cs class. |
- First convert the application to MC#
- Create a new M# .NET Core app
- Copy these files from the converted MC# app to the newly generated .NET Core app:
- M#\Model*.*
- M#\UI*.*
The following elements are renamed in the framework. In your application, you should change all references to the old names.
- MSharp.Framework → Olive
- Database.Find() → Database.FirstOrDefualt()
- Document → Blob
- IEmailQueueItem → IEmailMessage
- IApplicationEvent → IAuditEvent
- IHttpActionResult → IActionResult or Task
- RoutePrefix(Attribute) → Route(Attribute).
- [Authorized] → [JwtAuthenticate]
- Most extension methods which were defined in the System (namespace) before. Now they are in Olive. When you face missing methods, check the suggested using-list.
- Many methods are changed to async. When your method calls them, your method should also become async. This is recursive all the way up.
- If you use email sending:
- If your new app is a monolithm add a NuGet reference to
Olive.Emailpackage - If your new app is a Microservice, just reference the
EmailService.EmailApinuget package and use that, similar to other microservices.- Replace all
Database.Save(new EmailQueueITem....withEmailApi.Fresh().Send(new Email {
- Replace all
- If your new app is a monolithm add a NuGet reference to
- If your new app is a Microservice, remove
ApplicationEvententity. Logging is handled centrally in Microservices (in Audit service). - Instead of using User in the controllers and views to reference the current user use GetUser() method.