Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF with Azure - Mixing SQL Server and Windows Azure Storage

I want to use two different data sources in my Azure project:

  • a SQL Server that contains basic partial info regarding an item (allows indexable data and spatial search)
  • a Windows Azure Storage that contains full remaining info regarding an item (retrieved by key)

In this way I can combine the powerful of SQL Server with the easy scalability of Windows Azure Storage.

Imagine this Domain POCO class:

class Person
{
   string Id { get; set; }
   string Name { get; set; }
   byte[] Picture { get; set; }
   string Biography { get; set; }
}

I would like to use Entity Framework with fluent mapping to let EF understand that the properties Picture and Biography must be loaded from Windows Azure Storage (table, blob) instead of SQL Server (possibly Lazy loaded).

There's a way with EF (or NHibernate) to do this or I have to implement my own ORM strategy?

Thanks

like image 518
Ricibald Avatar asked Sep 28 '11 08:09

Ricibald


People also ask

Is Azure table storage cheaper than Azure SQL Database?

Azure tables are only cheaper than SQL Azure if the data access pattern is relatively light, since tables have a per-transaction fee and SQL Azure doesn't.

Which type of storage should be used in conjunction with Azure VMS for SQL Server data files?

Most customers use managed disks, available in a number of offerings: Standard HDD, Standard SSD, Premium SSD, and Ultra SSD. Managed disks are highly recommended to use over unmanaged disks (see Azure Managed vs Unmanaged disks : The choice). You create and then attach one or more managed disks to the VM.

How would you configure storage for a SQL Server VM running in Azure?

Sign into the Azure portal. Navigate to your virtual machine, select Disks under Settings. Choose the appropriate caching policy for your disk from the drop-down. After the change takes effect, reboot the SQL Server VM and start the SQL Server service.


1 Answers

I don't think you can let EF know about Azure storage but you can map only necessary properties to a specific table. For example,

 modelBuilder.Entity<Person>().Ignore(p => p.Picture); 

So assuming that you have a repository class for your Person class, what you want can be easily achieved by filling the repository class with Azure storage API and EF.

like image 122
Tae-Sung Shin Avatar answered Oct 21 '22 21:10

Tae-Sung Shin