Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Advanced Tutorial or book on Databases and EF

$
0
0

I need to create a persistent database for my webapp.

So far I've been following a book but in order to set up the database, it uses SQL statements.

I'm not generally opposed to SQL, quite often I prefer a minimal wrapper with a clean interface to a complete reimplementation. But people have told me wonderful things about Asp.Net and the entity framework, now I would like to see them in action.

I've read the two getting started guides in docs the This is my understanding so far:

  1. You write normal C# classes
  2.  You add attributes like [Required]
  3. You create a DBContext subclass with all the data you want to have
  4. You use dnx and ef to create a "migration"
  5.  You instantiate your DBContext, use DI to pass it around and everytime a change is made, you call "SaveChanges"

I don't feel in control of this workflow. And since the database will contain important data, I need to know exactly what I'm doing.

So here are my questions:

  • How are models identified ? What if you don't have any attributes to declare ? Sure, that seems unlikely but is there a way to explicitly register which c# classes need to be represented in SQL ?
  • How does the custom DBContext keep track of its data ? Apparently you can just add members and they will somehow be serialized. Does it work with introspection ?
  • How do migrations work ? What if the representation of the data needs to be updated ? Is there something like a merge tool ? Is there something like a rollback ?
  • Is there a central configuration file ? My source code is kept in a repo. I don't want to store the database in the repo but I need to know if dnx can recreate it in case of a crash. Does it keep track of configuration information ? I don't mean the data itself, just the structure of the database.

I realize that there are many questions and that they are very complex. Could you point me to a good (up-to-date) resource ? An in-depth-tutorial or a good book would be perfect.


Viewing all articles
Browse latest Browse all 9386

Trending Articles