Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dapper Extensions Change Schema

I am using Dapper Extensions to do some simple CRUD operations on a DB. My problem is that the tables I am using are held in a different schema to dbo. Is there a way to choose the schema at the dapper extensions level?

or

Should this be dealt with via the user that is being used to connect to the db with?

like image 733
Mathew Padley Avatar asked Dec 05 '13 12:12

Mathew Padley


1 Answers

You can use the AutoClassMapper to assign a new schema to your model. An overview on this is on the extensions site. You will basically need to create an AutoClassMapper per model with a different schema. The best place to declare it is alongside your model itself like:

public class MyModel 
{
  public Guid Id { get; set; } 
}

public class MyModelMapper : AutoClassMapper<MyModel>
{
  public MyModelMapper() : base()
  {
    Schema("YourNewSchema");
  }
}
like image 68
Wolfwyrd Avatar answered Sep 28 '22 09:09

Wolfwyrd