Database.SetInitializer() in a static constructor?
问题 Many are perhaps aware of why we need to use the code shown below. However, I want to separate this logic into layers and I don't want to reference the Entity Framework DLL in my web layer, thus I ended up putting this code in a static constructor of my DbContext class. Is this a bad idea? Will there be a performance hit on the app by doing this? Database.SetInitializer<DataContext<T>>(null); 回答1: There is no performance hit that is worth to be mentioned. A static constructor is called once