What's the equivalent of NotMapped attribute and AsNoTracking method in Fluent Migrator .Net ORM. I'm migrating one of my project which used EF6 as ORM to Fluent Migrator. I google a lot regarding this but couldn't find any helpful information.
FluentMigrator is an open source project to manage the schema of your data bases, claims to be a .Net implementation similar to
Ruby on Rails Migrations
, you should post issues and feedback in the issues or discussion forum for that project on github as their community is still active in 2020.
Because Fluent Migrator is not an ORM itself, it only manages the data schema, the question is therefor not properly formed.
EF has it's own schema migration management, Code First Migrations that interprets [NotMapped]
to omit the field from the database schema, and to ignore it when mapping results of queries into the data object model.
Project transitions from EF are commonly to NHibernate or Dapper, for this response I will assume NHibernate, because if you were still using EF the problem does not exist but hopefully the thought process will help you find the answer if you are using a different ORM.
NotMapped
As elaborated above, the NotMapped
attribute in EF is interpreted by both the data schema migrations AND the ORM. In the configuration for Fluent Migrator you manually specify the fields to manipulate in the data schema, so simply omit the field from Create/Alter table statements altogether.
If you are changing a field to be no longer stored in the database, then you can add a Delete.Column
command:
Delete.Column("ColumnName".FromTable("TableName").InSchema("dbo");
Use NotColumn attribute
In ORMs like NHibernate the same is true, simply do not map the property in the mapping configuration.
AsNoTracking
If you are still using EF6 as the ORM, then this doesn't change, Fluent Migrator is about schema maintenance and manipulation, not data querying.
AsNoTracking()
in an EF query disables change tracking and caching and as a by-product allows a query to return multiple records with duplicate key values in a single response, it is unclear from OP what context AsNoTracking()
is being used, but important to identify why is 'might' be used,
As far as I'm aware, Linq2Db does not track changes, its primary function is to translate Linq queries into SQL and execute that SQL, that said AsNoTracking
has caching implications so the closest I can find in linq2db is to use NoLinqCache to create a scope where the executions will not be cached:
using (var db = new MyDataConnection())
using (NoLinqCache.Scope())
{
var query = db.Users.Where(x => Sql.Ext.In(x.Id, ids));
}
For readers using NHibernate, you can consult the read-only entities documentation.
You can set al queries in a session as readonly usingsession.DefaultReadonly = true
Alternatively you can set a single query to be readonly:
query.SetReadonly(true);